Difference between revisions of "Ns formvalueput"
Jump to navigation
Jump to search
(Oops. Testing examples found problems. THere will be more edits.) |
(Added examples. Noted a bunch of bugs. Will annotate ns_tagelement too.) |
||
Line 27: | Line 27: | ||
'''EXAMPLES''' | '''EXAMPLES''' | ||
+ | Check box "a" from the set a, b: | ||
<pre><nowiki> | <pre><nowiki> | ||
+ | % 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>] | ||
</nowiki></pre> | </nowiki></pre> | ||
+ | Set the value of hidden form field "foo" to "bar" | ||
+ | <pre><nowiki> | ||
+ | % set hidden {<input type="hidden" name="foo">} | ||
+ | <input type="hidden" name="foo"/> | ||
+ | |||
+ | % ns_formvalueput $hidden foo bar | ||
+ | <input type="hidden" name="foo" value="bar"> | ||
+ | </nowiki></pre> | ||
+ | Set the value of textarea "textarea" to "new value": | ||
+ | <pre><nowiki> | ||
+ | % 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> | ||
+ | </nowiki></pre> | ||
+ | |||
'''NOTES''' | '''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 or to create well-formed XHTML 1.0 documents: | ||
+ | ** The CHECKED and SELECTED attributes are minimized (i.e., have no value) and are always in upper case. | ||
+ | ** <nowiki><input></nowiki> elements encoded using the XML syntax <nowiki><input </nowiki>'''/>''' will cause syntax errors in the output. | ||
---- | ---- | ||
[[Category Documentation]] - [[Category Core Tcl API]] | [[Category Documentation]] - [[Category Core Tcl API]] |
Revision as of 21:44, 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 or to create well-formed XHTML 1.0 documents:
- 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.