Greetings,
I am having a yuk debugging problem. My ego is deflated.
I am trying to pass variables into a validation function (client-side) from multiple locations in my web site, so I want to use the "this" keyword from each form.
I have condensed the code into as small a chunk as possible as follows. (The loose doctype was a desperate gasp.):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TRhtml4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript">
function validateitem(objForm){
returnValue=false;
document.write("form element 'amount': " +objForm.amount.value+ "<br>\r");
document.write("form element 'item_name': " +objForm.item_name.value+ "<br>\r");
document.write("form element 'business': " +objForm.business.value+ "<br>\r");
return returnValue;
}
</script>
</head>
<body>
<form name="form1"
action="https://www.paypal.com/cgi-bin/webscr"
method="post"
onsubmit="return validateitem(this);">
<input type=hidden name="cmd" value="_cart">
<input type=hidden name="business" value="
[email protected]">
<input type=hidden name="item_name" value="Bulgarian Lavender">
<input type=hidden name="amount" value="12">
<input type=submit name="submit" value="Submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
</body>
</html>
Pressing the submit button produces the following error:
"'item_name.value' is null or not an object."
If I delete the .value as follows:
objForm.amount
objForm.item_name
then these values are returned as "undefined."
Ironically, If I switch the order of statements in the function as follows:
function validateitem(objForm){
returnValue=false;
document.write("form element 'item_name': " +objForm.item_name.value+ "<br>\r");
document.write("form element 'amount': " +objForm.amount.value+ "<br>\r");
document.write("form element 'business': " +objForm.business.value+ "<br>\r");
return returnValue;
}
then whichever write statement is written first, will correctly execute with the correct output, and the latter statements will be undefined.
Thank you very much for your time.
Daniel Hutchins
Thank you,
Daniel Hutchins
Woodbridge, CA
http://www.finehomemadesoap.com