Using page parameters in server scripts

If you are not using the 4GL interface to manage your page parameters, you can access parameters submitted to a page by writing server scripts.

Non-4GL pages

To make full use of the page parameters, you can have the server script generate a client script. This server-side script generates a client-side script that sets a text box value (on a Web page that is not 4GL enabled) to the id parameter:

psDocument.WriteLn("<script>");
psDocument.WriteLn("function setValues()");
psDocument.WriteLn("{");
   psDocument.WriteLn("myForm.sle_1.value='" +
      psDocument.GetParam("id")+ "'");
psDocument.WriteLn("}");
psDocument.WriteLn("</script>");

You can then code a client-side event (such as an onclick event for a button or the onload event for the page) to call the setValues function in the generated client-side script.

Passing a parameter in an anchor element

Passing page parameters from one page to another requires identifying the parameter (of the target page) on the linking page, then accessing the value in a server script on the target page. You can set up an anchor element or a form on the linking page to link to the page parameter of the target page.

On the linking page, create an anchor element (<A>). In the HREF attribute, specify the target URL with a query string appended to it. The query string can have one or more name-value pairs. A question mark separates the query string from the URL and an ampersand separates each name-value pair. The format is:

 url?name1=value1&name2=value

Example: passing data in a query string Here a link on the linking page goes to the target page nextpage.htm. There are two values passed in the query string: Data and Name. On the target page, the page parameter names are called Data and Name and their values are "1" and "Jane". Note that parameter names are case-sensitive.

<A HREF="nextpage.htm?Data=1&Name=Jane">Jane's data
</A>

Passing a parameter in a form

On the linking page, create a form for which the action is the URL of the target page. When the user submits the form, the form field names and values are passed to the target page as page parameters. Depending on the form method (GET or POST), the parameters are formatted as a query string or sent separately. No matter which method you use, server scripts on the target page see the values as page parameters.

Example: passing data from a form Here a form on the linking page asks the user to specify a name and a number. On the target page, nextpage.htm, the page parameters are called "Name" and "Data", and their values are whatever the user entered in the form fields.

<FORM id=FORM1 name=NameAndData action="nextpage.htm" 	
      method=post> 

User Name: <INPUT id=INPUT1 name="Name" type="TEXT">
Number of requests: <INPUT id=INPUT2 name="Data" 
      type="TEXT">
<INPUT id=INPUT3 name="Submit" type=submit>
</FORM>

Accessing the value of a page parameter

In a server script on the target page, you can get the value of page parameters with the GetParam method.

Example Here the script gets the value of "Name" and "Data".

username = psDocument.GetParam("Name"); 
userdata =  psDocument.GetParam("Data");