Jump to content
  • 0

Displaying Parameters


freshstart

Question

I have 2 data pages. 1 is a submission form and the other is a results page. I am passing parameters from the submission form so that the results page finds the correct information from the database for display.

 

My database records have several fields, but for the purpose of this question I will only use 3 of the fields.

 

Field 1: Store Name

Field 2: Category

Field 3: State

 

Some of the stores are located in multiple states. Many are in all 50 states.

Rather than creating a separate record for each store/category/state I have put all states for that store name into the state field, with each separated by a comma.

 

 When I submit my search using a "contains" format I have no problem finding each record that I am searching for, but I don't want to display all of the text that can be found in the state field, I only want to display the parameter that was passed when I ran the search.

 

Is there any way to display the parameter on my results page and not the actual text found in the state field?

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Thanks so much. I used the html block and it worked great except for 1 thing. I have my dropdown lists setup to allow "All" to be selected. When "All" is selected I cannot get the word "All" to show up using html, it just gives me a blank. I am assuming it is because no value is assigned to this option. Any suggestions?

Link to comment
Share on other sites

  • 0

Hello freshstart,

 

If I understand correctly, you can use a JavaScript code to pass the value of the selected item.

 

Please follow the next steps:

Add a Virtual field to your Submission form, and then select Hidden in the Foem element dropdown;

Pass the value of this Hidden Virtual filed as parameter;

Add the Header&Footer element to your Submission form and enter the following code to the Footer:

<SCRIPT LANGUAGE="JavaScript">
function insert_parameter()
{
var selected = document.getElementById("InsertRecordDROPDOWN");
var value_parameter = selected.options[selected.selectedIndex].text;
document.getElementById("cbParamVirtual1").value = value_parameter;
}
document.getElementById("caspioform").onsubmit=insert_parameter;
</SCRIPT>

Please enter the name of your field instead of DROPDOWN in the InsertRecordDROPDOWN.

If the name of your Hidden Virtual field is not Virtual1, then enter the number of your Virtual field instead of 1 in cbParamVirtual1.

 

On the Report DataPage use the passed parameter in your HTML block.
 
I hope it helps. 
Link to comment
Share on other sites

  • 0

I don't think this is what I need, although I may not be explaining my problem clearly.

 

I am using virtual fields to pass the parameters from my submission form dropdowns to my results page. I am using html to show the parameter being passed. It is working fine unless the selection is "All".

 

When I set up my dropdowns in the submission form I use a lookup table and also a custom value set to "All" with no value so that users can select this option and see all records. Since the "All" option has no value there is no value being passed when this option is selected.

 

I would like to display the word "All" on my results page when and only when the user selects "All" from my dropdown on the submission form. Any other selection is passing the parameter and displaying it perfectly.

 

Is it possible to use an "if" statement to assign a value when no value is passed? If so how would I do that? I don't know anything about javascript and very little about html.

 

Thanks, I appreciate your help.

Link to comment
Share on other sites

  • 0

I don't think this is what I need, although I may not be explaining my problem clearly.

 

I am using virtual fields to pass the parameters from my submission form dropdowns to my results page. I am using html to show the parameter being passed. It is working fine unless the selection is "All".

 

When I set up my dropdowns in the submission form I use a lookup table and also a custom value set to "All" with no value so that users can select this option and see all records. Since the "All" option has no value there is no value being passed when this option is selected.

 

I would like to display the word "All" on my results page when and only when the user selects "All" from my dropdown on the submission form. Any other selection is passing the parameter and displaying it perfectly.

 

Is it possible to use an "if" statement to assign a value when no value is passed? If so how would I do that? I don't know anything about javascript and very little about html.

 

Thanks, I appreciate your help.

Link to comment
Share on other sites

  • 0

Hello freshstart,

 

As far as I know, you cannot use "if" on the Report page to check whether the parameter is empty. I tried several ways, but they all failed.

And you should pass the empty parameter to find all values, so, I think, the best way is to use two parameters: one will be used in the search and the second will be displayed in the HTML block.

 

Also, you can display a Search Interface and a Results Set page on the one page.

Link to comment
Share on other sites

  • 0

Hi - Just wanted to share this solution. If you would like to get and display a field value/external parameter on an external HTML page, you can follow these steps:

1. Add an HTML code as a holder of the parameter, for example:

<span id="user"></span>

2. Insert a JavaScript, call and display the parameter in the holder.

<script>

const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const userParam = urlParams.get('param');
document.getElementById("user").innerHTML = userParam;

</script>

The param is the name of the parameter from an external URL.

For reference: https://stackoverflow.com/questions/71727647/displaying-url-parameter-values-as-text-in-an-element-on-webpage-question-from

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...