<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1458" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Thanks for the suggestions, Flavio. Here's
what I've learned. Apparantly, the <EM>-onsubmit</EM> clause needs to be
associated with the form to scope the form elements into the
<FONT face="Times New Roman" size=3>checkForm( )</FONT> function.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV><FONT face=Arial size=2># Client-side JavaScript Generated with the Perl
CGI:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>print qq(<script><!--<BR> function checkForm (
form ) {<BR> var
clicked=arguments[1]; // do this for "readability"; . . .points to
2nd arg!<BR></DIV>
<DIV> if ( clicked = =
"Update")</DIV>
<DIV> || clicked = =
"Insert")
{<BR> if (
form["vendor_name"].value = = "")
{<BR>
alert("Vendor Name is
required");<BR>
return
false;<BR>
}<BR><FONT face=Arial
size=2>// <EM> other
similar conditionals can be added per above.</EM></FONT></DIV>
<DIV>
}<BR> return
true;<BR> }<BR> //
--></script><BR>);<BR><FONT face=Arial size=2>~</FONT></DIV>
<DIV><FONT face=Arial size=2>~ <EM>etc.</EM></FONT></DIV>
<DIV><FONT face=Arial
size=2>~</FONT><BR>$cgi->start_form(-action=>'vendors_01.pl',<BR>
-method=>'GET',<BR>
-name=>'vendors_01.pl',<BR>
-onsubmit=>"return checkForm( this, clicked )"<BR>
);<BR></DIV></BLOCKQUOTE>
<DIV dir=ltr><FONT face=Arial size=2>The submit buttons are defined as
follows:</FONT></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV dir=ltr>$cgi-> submit(-name=>"action",
-value=>"Inquire", -onclick=>"clicked=value"),<BR>$cgi->
submit(-name=>"action", -value=>"Update",
-onclick=>"clicked=value"),<BR>$cgi-> submit(-name=>"action",
-value=>"Insert",
-onclick=>"clicked=value"),<BR>$cgi-> submit(-name=>"action",
-value=>"Delete",
-onclick=>"clicked=value"),</DIV></BLOCKQUOTE>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I'm not sure exactly how the value assigned to the
var, "clicked" is passed to the checkForm functions, but is is passed as the
second argument to the function. It does work.</FONT><BR></DIV>
<DIV><FONT face=Arial size=2>OTTF,<BR>Ron Wingfield</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=1>FreeBSD 4.8 -- Apache http 2.0.28 --
MySQL client/server 4.1.7<BR>Perl 5.8.5 -- p5-DBD-mysql-2.9004 driver --
p5-DBI-1.46</FONT><BR></DIV>
<DIV>
<HR>
</DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=flavio@economisa.com.br href="mailto:flavio@economisa.com.br">Flavio
Gomes</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=javascript@LaTech.edu
href="mailto:javascript@LaTech.edu">[JavaScript List]</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, January 21, 2005 12:02
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Javascript] Test or
Identify Value of Submit Button's AssignedValue</DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial
size=2></FONT><BR></DIV>Hello Ron,<BR><BR><BR>Maybe changing your
checkForm to something
like<BR><BR> function
checkForm(pressedSubmit) { ... }<BR><BR>then call it
as<BR><BR> <input
type=submit onclick="checkForm(this.value)" name=action
<BR>value=Inquire><BR>
<input type=submit onclick="checkForm(this.value)" name=action
<BR>value=Update><BR><BR>Or you could set a variable initiated with the
default "value" of the <BR>submit, and when the user clicks the button (the
submit) it changes the <BR>variable value to it's(button's)
value.<BR><BR>--<BR>Flavio Gomes<BR><A
href="mailto:flavio@economisa.com.br">flavio@economisa.com.br</A><BR><BR><BR><BR>Ron
Wingfield wrote:<BR><BR>> I have defined some submit buttons, e.g., assoc/w
"Inquire", "Update", <BR>> etc., as follows:<BR>>
<BR>><BR>> $cgi-> submit(-name=>"action",
-value=>"Inquire"),<BR>> $cgi->
submit(-name=>"action", -value=>"Update"),<BR>><BR>> Regarding the
first "if" condition in the following JavaScript code <BR>> (from the
checkForm function executed -onsubmit), the value of " <BR>>
form["action"].value " is /undefined/ (. . .at least at the point in <BR>>
my code); however, the value of " form[''name"].value " is the value <BR>>
as typed in the form's /Name/ field.
<BR>><BR>>
if ( form["action"].value == "Update")
{<BR>>
if ( form["name"].value == "")
{<BR>>
alert("Name is
required");<BR>>
return
false;<BR>>
}<BR>>
}<BR>><BR>> Obviously, the following -onsubmit condition is executing
the <BR>> JavaScript. In the client-side JavaScript, how do I test
the value of <BR>> the clicked submit button? In other words, I need
to know which <BR>> submit button was
clicked.<BR>><BR>><BR>>
$cgi->start_form(-action=>'vendors_01.pl',<BR>>
-method=>'GET',<BR>>
-name=>'vendors_01.pl',<BR>>
-onsubmit=>"return checkForm( this );" );<BR>><BR>> Thanks,<BR>>
Ron Wingfield<BR>> <BR>> FreeBSD 4.8 -- Apache http
2.0.28 -- MySQL client/server 4.1.7<BR>> Perl 5.8.5 -- p5-DBD-mysql-2.9004
driver --
p5-DBI-1.46<BR><BR><BR>_______________________________________________<BR>Javascript
mailing list<BR><A
href="mailto:Javascript@LaTech.edu">Javascript@LaTech.edu</A><BR><A
href="https://lists.LaTech.edu/mailman/listinfo/javascript">https://lists.LaTech.edu/mailman/listinfo/javascript</A><BR></BLOCKQUOTE></BODY></HTML>