Lasso Soft Inc. > Home

[ web_request->param ]

Method

The [web_request->param] method returns the query or post parameter whose name is specified as the first argument. It can take an optional second argument that specifies how to join multiple instances of the named parameter.

If the second parameter is any value which does not evaluate as "true"—such as null or false—then the parameters will be returned in a staticarray object, regardless of the number of parameters available.

If there are no parameters which match the name, then void is returned.

  • Syntax
web_request->param('Param Name')
web_request->param('Param Name', 'Separator')
web_request->param('Param Name', Any "Non-True" Value)
Examples
  • Beginner

Join together and display multiple values for a parameter

The code below will display all the instances of the parameter 'title' joined together with a comma. For purposes of the result, assume that this code is on a page that was called from a page with the following code:

<form method="post" action="?title=M.D.">
    <input type="text" name="title" value="Ph.D." />
    <input type="submit" value="Test" />
</form>

Code

web_request->param('title', ', ')

Result

Ph.D., M.D.

To test whether a parameter has been submitted:

Use the [web_request->param] method. The code below will test whether the parameter 'rhino' is submitted.

Code

<form method="post" action="?title=M.D.">
    <input type="text" name="title" value="Ph.D." />
    <input type="submit" value="Test" />
</form>

[web_request->param('rhino', false)===void]

Result

true

To return a staticarray of the values for a named parameter:

Use the [web_request->param] method. The code below will return all submitted values for the named parameter 'title' as a staticarray. This may be especially useful for checkboxes and multiple select form inputs.

Code

<form method="post" action="?title=M.D.">
    <input type="text" name="title" value="Ph.D." />
    <input type="submit" value="Test" />
</form>
[web_request->param('title', false)]

Result

staticarray(Ph.D., M.D.)

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft