Kbase 18862: How to Save an HTML Checkbox Field Into a Logical Variable
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/10/2008 |
|
Status: Verified
GOAL:
How to Save an HTML Checkbox Field Into a Logical Variable
FIX:
When an HTML checkbox field is submitted from a web browser it sends the value used in the VALUE option only if the field is checked. It does not send any information if the field is not checked.
The get-field function would return blank when the field is unchecked.
When using the get-field function directly to assign the checkbox into a variable or database field, to test for the empty string using a code like the following:
ASSIGN my_table.logical_fld =
(IF get-field("my_table.logical_fld") <> ""
THEN TRUE ELSE FALSE).
or
ASSIGN my_table.logical_fld =
(IF get-field("my_table.logical_fld") = "*value*"
THEN TRUE ELSE FALSE).
Where *value* is the value used in the VALUE option of the HTML field.
The following HTML program demonstrates the way that web browsers pass the value of a checkbox to the web server.
<FORM METHOD="GET" ACTION="test.htm">
<INPUT TYPE="CHECKBOX" NAME="test" VALUE="yes">
<INPUT TYPE="SUBMIT">
</FORM>
In the web browser url test.htm?test=yes when the field is checked and test.htm? otherwise.