Show TOC

Implementing CheckboxesLocate this document in the navigation structure

Use

To implement checkboxes in Web transactions, you identify them in HTML templates by the names assigned in the Screen Painter. A checkbox field is always mapped to a character field with a length of 1. The value of this field is either blank or you assign a value like 'X'.

The handling of checkboxes by Web browsers can cause problems:

  • If a checkbox is checked, the Web browser transmits the state of the checkbox to the Web server.

  • If a checkbox is not checked, the Web browser transmits nothing to the Web server when the form is posted, so the Internet Transaction Server (ITS) receives no value and the called program has no knowledge of the checkbox variable.

To reset a checkbox to blank, you can use a hidden HTML field and assign the value ' ' to the checkbox field name. Since hidden HTML fields are always sent by the Web browser, the ITS receives the value ' ', which resets the checkbox on the SAP system screen.

Although the HTML contains the hidden HTML field, the value 'X' is transferred to the ITS if the checkbox is set and if it is specified after the hidden HTML form input field, because it takes precedence over the hidden HTML field.

To find out the current state of a checkbox on the SAP system screen in HTML, you can use the checked attribute:

  • If the checkbox is set on the SAP system screen, the name assigned in the Screen Painter contains 'X'.

    You can use the HTMLBusiness statement if to set the checked attribute of the checkbox depending on the value of the SAP system screen field.

Example
<FORM ACTION="~wgateUrl()" METHOD="POST">
<INPUT TYPE="HIDDEN"   NAME="OPTION_1" VALUE=" ">
<INPUT TYPE="CHECKBOX" NAME="OPTION_1" VALUE="X"
                `if ( OPTION_1 == "X" )` checked `end` >
<INPUT TYPE="HIDDEN"   NAME="OPTION_2" VALUE=" ">
<INPUT TYPE="CHECKBOX" NAME="OPTION_2" VALUE="X"
                `if ( OPTION_2 == "X" )` checked `end` >
<INPUT TYPE="HIDDEN"   NAME="OPTION_3" VALUE=" ">
<INPUT TYPE="CHECKBOX" NAME="OPTION_3" VALUE="X"
                `if ( OPTION_3 == "X" )` checked `end` >
</FORM>