[Javascript] Test or Identify Value of Submit Button's Assigned Value
Ron Wingfield
rtwingfield at archaxis.net
Fri Jan 21 11:56:22 CST 2005
I have defined some submit buttons, e.g., assoc/w "Inquire", "Update", etc., as follows:
$cgi-> submit(-name=>"action", -value=>"Inquire"),
$cgi-> submit(-name=>"action", -value=>"Update"),
Regarding the first "if" condition in the following JavaScript code (from the checkForm function executed -onsubmit), the value of " form["action"].value " is undefined (. . .at least at the point in my code); however, the value of " form[''name"].value " is the value as typed in the form's Name field.
if ( form["action"].value == "Update") {
if ( form["name"].value == "") {
alert("Name is required");
return false;
}
}
Obviously, the following -onsubmit condition is executing the JavaScript. In the client-side JavaScript, how do I test the value of the clicked submit button? In other words, I need to know which submit button was clicked.
$cgi->start_form(-action=>'vendors_01.pl',
-method=>'GET',
-name=>'vendors_01.pl',
-onsubmit=>"return checkForm( this );" );
Thanks,
Ron Wingfield
FreeBSD 4.8 -- Apache http 2.0.28 -- MySQL client/server 4.1.7
Perl 5.8.5 -- p5-DBD-mysql-2.9004 driver -- p5-DBI-1.46
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20050121/b756ec0b/attachment.htm>
More information about the Javascript
mailing list