Consultor Eletrônico



Kbase 22072: Webspeed (3.x) Determining Which Button the User Selected
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/06/2002
SUMMARY:

Interface designs might provide Web application users several options to choose from on a particular form. This Knowledge Base Solutions gives an example of how to determine which form button was selected by the user.

EXPLANATION:

The process simply uses the same name for all of the buttons, then uses the 4GL and the get-value("") command to determine what the next set of events should be. The example only displays the value selected.

There are several variations of processes that can be implemented using this basic model. Remember to enclose your processing in the Procedure Output-header located in the <Head> of the document when doing processes that should be executed before the HTML is generated.

Some processes you may invoke in this output-header procedure would be HTTP redirects, Case Statements, If... Then Statements, or Value calculations.

SOLUTION:

Save the following code as buttontest.html

====================================================================

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<META NAME="AUTHOR" CONTENT="Alex Pearlstein">
<TITLE>WebSpeed Get Button Value Example</TITLE>
<SCRIPT LANGUAGE="SpeedScript">
Procedure output-header:
/* here you can do processing on the value */
/* or directed by the value of get-value("SBN") */
/* All code in this Procedure is processed before */
/* the HTML is generated */
End Procedure.
</SCRIPT>
</HEAD>

<BODY>
<Center>
<Form method="Post" Action="buttontest.html" name="Form">
<Table>
<TR><TD colspan=3><Center>Select a button</TD></TR>
<TR>
<TD><input type="submit" name="SBN" value="One"></TD>
<TD><input type="submit" name="SBN" value="Two"></TD>
<TD><input type="submit" name="SBN" value="Three"></TD>
</TR>
<TR><TD colspan=3><Center>
<SCRIPT LANGUAGE="SpeedScript">
IF get-value("SBN") gt "" THEN
{&out} 'You pressed ' + get-value("SBN").
else ''.

</SCRIPT>
</TD></TR>
</Table>
</BODY>
</HTML>

=====================================================================