Problem:
This shows how to disable an html text input field programmatically through the CGI program and JavaScript code
Resolution:
INTRODUCTION
==========
This demo shows how to disable an html text input field programatically through the CGI program
and Javascript code.
SOURCE FILES:
==========
Program Files Description
------------------- -----------------------------------------------------------
disablefield.app project file
mycgi.cbl Internet App Wizard generated cgi program
Copy Files:
------------------- -----------------------------------------------------------
mycgi.cpf Form fields copyfile
mycgi.cpy Copyfile of fields to be used in business processing
mycgi.cpv Conversion routines copyfile
Form Files:
------------------- -----------------------------------------------------------
HTMLPage.htm Html input and output page created in Form Designer
HTMLPage.mff Form Designer file
REQUIREMENTS:
==========
This demo was tested using Microsoft Internet Explorer version 6. It was not tested with any other browsers so results may differ if another is used.
OPERATION:
========
Open the disablefield.app project, and double-click the HTMLPage.htm file to load it in Form Designer. Notice that I added a "hidden input" form element (named hidden1) next to the submit button. Now, select the "Edit" menu from the Net Express menu bar. From the "Edit" menu, choose the "Events..." menu item to bring up the Script Assistant. In the treeview of objects on the left, select "body1" and then scroll through the events list on the right to find the "onload" event which is check-marked. Click on it to select it and notice the Javascript code in the window below:
function body1_onload_func()
{
if (form1.hidden1.value == "d")
{
form1.input1.disabled = "true"
}
}
This function will execute because of the onload attribute of the html BODY tag. The "if" test checks the value of the hidden field and if it contains the value "d" (which can be moved to this field in the cgi program's business processing section), then the disabled property of the "input1" text input field is set to "true". The syntax form1.hidden1.value uses the Javascript DOM (Document Object Model).
Build and run the project. When the web page appears, you can enter the character "d" in the input field and submit the form. The output page will then have a disabled input field.
==========================================================
Keywords: demonstration, sample, example, demo, web programming, disablefield.zip
demo.ex
demo.ne
demo.se