|
ION Script User's Guide: Creating ION Script Applications |
|
Any name/value pairs passed in a URL query string to the ION Script parser will become ION Script variables in the page loaded by the URL. For example, consider the URL in the following ION Script page:
page1.ion:
<ION_SCRIPT> <ION_BODY> <A HREF="http://host/cgi-bin/ion- p.exe?page=page2.ion&var1=5&var2=abc">Pass var1 and var2 to page2.ion</A> </ION_BODY> </ION_SCRIPT>
When you click the link in the above page, the values var1 and var2 are passed to page2.ion. You can access these values on page2.ion as $Form.var1 and $Form.var2, as shown in the following example:
page2.ion:
<ION_SCRIPT> <ION_BODY> The value of var1 is <ION_VARIABLE NAME="$Form.var1"/>. <BR> The value of var2 is <ION_VARIABLE NAME="$Form.var2"/>. </ION_BODY> </ION_SCRIPT>
When you click the link on page1.ion, page2.ion displays the following:
The value of var1 is 5. The value of var2 is abc.
Instead of simply passing hard-coded values in a URL as in the above example, it is also possible to pass ION Script variables in a URL. To do so, you must insert the ION Script variable in the URL query string by using the ION_VARIABLE tag as follows:
page1.ion:
<ION_SCRIPT> <ION_HEADER> <VARIABLES> <VARIABLE_DECL NAME="A" TYPE="INT" VALUE="10"/> </VARIABLES> </ION_HEADER> <ION_BODY> <A HREF= http://host/cgi-bin/ion-p.exe?page=page2.ion&var1= <ION_VARIABLE NAME="$A"/>>Page 2</A> </ION_BODY> </ION_SCRIPT>
page2.ion:
<ION_SCRIPT> <ION_BODY> The value of the ION Script variable passed in the URL for this page is <ION_VARIABLE NAME="$Form.var1"/>. </ION_BODY> </ION_SCRIPT>
When you click the link on page1.ion, page2.ion displays the following:
The value of the ION Script variable passed in the URL for this page is 10.
If you pass a URL to the ION Script parser, and the URL contains a query string in which more than one name/value pair uses the same name, then a single $Form variable is created in which the values assigned to the variable are separated by the "|" character. For example, if you pass to the ION Script parser the URL
http://host/cgi-bin/ion-p.exe?var1=One&var1=Two&var1=Three
then a $Form variable named $Form.var1 will be created with the value "One|Two|Three".
This functionality is helpful when you use the MULTIPLE attribute to the SELECT element to allow the user to select multiple options from a drop-down list. In this case, each of the options selected by the user will be appended to the $Form variable and separated by the "|" character when the form is submitted. You must then parse the $Form variable to extract the values. For an example of how to use the MULTIPLE attribute of the SELECT tag, see Handling Multiple Selections in a SELECT Element.
IDL Online Help (March 06, 2007)