Kbase 17255: How to get name/value from input form without hard-coding
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
How to get name/value from input form without hard-coding
How to gather information from an input form
============================================
An HTML input form provides a method for users to
enter information and SUBMIT it by pressing a
SUBMIT button. When the SUBMIT button is
pressed a form action is taken. This may mean that
another web object is run that will
gather this information that the user typed in.
The form action that runs when the SUBMIT button is
pressed can access this information with calls to
get-value() and get-field() etc that specifically
refer to the names of the fields on the input form.
For instance,
An input form that contains a radio-set with the name of
RAD1 can have it's value accessed by the form action
in the following manner:
def var x as char.
x = get-value("RAD2").
Getting values without hard-coded names
======================================
In some cases, you may not want to hard-code the name
of each and every input field (you may want to re-use this
code as the form action for several forms where the names
and number of items may be different). Here is an example of how
to do this:
...
</head>
...
<body>
<script language="SpeedScript">
def var outfld as char.
outfld = get-field(?).
def var idx as int.
def var x as char.
do idx = 1 to num-entries(outfld):
if entry(idx,outfld) NE "submit" then do:
x = get-field(entry(idx,outfld)).
{&out} "value is " x.
end.
else {&out} "done".
end.
</script>
</body>
...
</html>
In the above example, the get-field(?) returns all the name/value
pairs on the input form (including the SUBMIT button) in one character
string 'outfld'. The DO loop parses out each item's name which
can then be used in a call to get-field() to get it's value.
Progress Software Technical Support Note # 17255