Difference between revisions of "Ns formvalueput"
Jump to navigation
Jump to search
(OK, I think it's correct now :-)) |
m (typo) |
||
Line 51: | Line 51: | ||
<pre><nowiki> | <pre><nowiki> | ||
% set hidden {<input type="hidden" name="foo">} | % set hidden {<input type="hidden" name="foo">} | ||
− | <input type="hidden" name="foo" | + | <input type="hidden" name="foo"> |
% ns_formvalueput $hidden foo bar | % ns_formvalueput $hidden foo bar |
Revision as of 21:55, 8 February 2008
Man page: not in source tree
NAME
- ns_formvalueput - Sets the value of input elements in HTML documents
SYNOPSIS
- ns_formvalueput htmlpiece dataname datavalue
DESCRIPTION
- This command sets the value of an HTML input element with NAME=dataname (of any type) to the given datavalue. In the following descriptions, all attribute names are handled in case-insensitive fashion (as required by HTML)
- The elements (tags) & types supported are:
- INPUT
- image
- ignored
- submit
- ignored
- reset
- ignored
- checkbox
- will be checked if the NAME attribute matches the dataname (case insensitive) and the VALUE attribute matches the datavalue (case-sensitive)
- radio
- will be checked if the NAME attribute matches the dataname (case insensitive) and the VALUE attribute matches the datavalue (case-sensitive)
- TEXTAREA
- If the NAME attribute matches the dataname, all the enclosed text up to the next </textarea> tag will be replaced by the datavalue.
- SELECT
- If the NAME attribute of the SELECT tag matches the dataname, this will find the first enclosed OPTION tag with a VALUE attribute that matches datavalue, and set its SELECTED attribute. All other enclosed OPTION tags will have their SELECTED attribute removed.
EXAMPLES
- Check box "a" from the set a, b:
% set checks {<form> <input type="checkbox" name="ex" value="a">a</input> <input type="checkbox" name="ex" value="b">b</input> </form> } <form> <input type="checkbox" name="ex" value="a">a</input> <input type="checkbox" name="ex" value="b">b</input> </form> % ns_formvalueput $checks ex a <form> <input type="checkbox" name="ex" value="a" CHECKED>a</input> <input type="checkbox" name="ex" value="b">b</input> </form>
- Set the value of hidden form field "foo" to "bar"
% set hidden {<input type="hidden" name="foo">} <input type="hidden" name="foo"> % ns_formvalueput $hidden foo bar <input type="hidden" name="foo" value="bar">
- Set the value of textarea "textarea" to "new value":
% set ta {<form> <textarea name=textarea>Old value</textarea> </form>} <form> <textarea name=textarea>Old value</textarea> </form> % ns_formvalueput $ta textarea {new value} <form> <textarea name=textarea>new value</textarea> </form>
NOTES
- In AOLServer 4.5.0 (and all previous versions):
- Checkboxes are treated exactly like radio buttons. That is, all other boxes with the same name are unchecked.
- There is no mechanism for explicitly unchecking a checkbox.
- In part because ns_tagelement does not strip single quotes from attribute values, the type, name, and value attribute values for each element must be either bare or enclosed by double quotes.
- Ns_formvalueput cannot be used with well-formed XHTML 1.0 documents, nor will it create them:
- The CHECKED and SELECTED attributes are minimized (i.e., have no value) and are always in upper case.
- <input> elements encoded using the XML syntax <input /> will cause syntax errors in the output (the value attribute is inserted between the trailing / and the trailing >).