$Web Form Action: Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 22: Line 22:
==Usage notes==
==Usage notes==
<ul>
<ul>
<li><var>$Web_Form_Action</var>, as the name might suggest, is most useful in generating the URL for the "action" attribute of the <form> tag in HTML. This is especially useful if the current URL includes ISINDEX data that might be relatively difficult to reconstruct otherwise. The following demonstrates how one might use the <var>$Web_Form_Action</var> function in a form generated with the HTML statement.
<li><var>$Web_Form_Action</var>, as the name might suggest, is most useful in generating the URL for the "action" attribute of the <code><form></code> tag in HTML. This is especially useful if the current URL includes ISINDEX data that might be relatively difficult to reconstruct otherwise. The following demonstrates how one might use the <var>$Web_Form_Action</var> function in a form generated with the HTML statement.


<p class="code">HTML
<p class="code">HTML

Revision as of 21:46, 15 June 2012

<section begin="desc" />Return action URL<section end="desc" />

$Web_Form_Action returns the relative URL of the current request.

$Web_Form_Action takes two arguments and returns a string.

Syntax

<section begin="syntax" /> %rc = $Web_Form_Action(pos, len) <section end="syntax" />

Syntax terms

%rc A numeric variable to contain the return code.
pos This numeric value is the starting position in the URL for the current request to be returned. This is an optional parameter, and it defaults to one, meaning that the current URL is returned starting at the first character.
len This numeric value is the maximum number of characters to be returned. This is an optional parameter and it defaults to 255.

Usage notes

  • $Web_Form_Action, as the name might suggest, is most useful in generating the URL for the "action" attribute of the <form> tag in HTML. This is especially useful if the current URL includes ISINDEX data that might be relatively difficult to reconstruct otherwise. The following demonstrates how one might use the $Web_Form_Action function in a form generated with the HTML statement.

    HTML <form method="POST" action="{$Web_Form_Action}">
    Name: <input size=20 type="text" name="name" value="{%NAME}">
    Rank: <input size=12 type="text" name="rank" value="{%RANK}">
    Serial number: <input size=12 type="text" name="serno" value="{%SERNO}">
    <input type="submit" value="Update"> </form> END HTML

    If there is a possibility that the current relative URL along with the ISINDEX data is longer than 255 bytes, $Web_Form_Action should be used in a loop in conjunction with $Web_Form_Action_Len as demonstrated here:

    PRINT '<form method="POST" action="' ... FOR %I FROM 1 TO $Web_Form_Action_Len BY 255 PRINT $Web_Form_Action(%I) ... END FOR PRINT '">'

See also