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.
web_request->param('Param Name')
web_request->param('Param Name', 'Separator')
web_request->param('Param Name', Any "Non-True" Value)
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.
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
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.)
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 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments