Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function calling error

Status
Not open for further replies.

sipps

Technical User
Feb 9, 2003
133
GB
Hi all,

I have a little function just to check that some boxes of my form have been filled in, and if they have, then submit the form. I keep getting this error though and I can't find out what is wrong with this script, it's probably something simple and I cant see it!

Here is the code:

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
function subForm(){
message = &quot;&quot;
if (document.existingcustomer.Username.value == &quot;&quot;){
message += &quot;\n- Username is blank&quot;
}
if (document.existingcustomer.Credit_Card_Number.value == &quot;&quot;){
message += &quot;\n- Credit Card Number is blank&quot;
}
if (document.existingcustomer.Expiry_Date.value == &quot;&quot;){
message += &quot;\n- Expiry Date is blank&quot;
}
if (document.existingcustomer.Customer_Password.value == &quot;&quot;){
message += &quot;\n- Password is blank&quot;
}
if (message != &quot;&quot;){
alert (&quot;Please correct the following:&quot; + message)
}
else{
document.existingcustomer.action = &quot;bookingconfirmed.php&quot;
document.existingcustomer.method = &quot;post&quot;
document.existingcustomer.submit()
}
}


</script>

And this is the link that calls the function:

<a href=&quot;JavaScript:document.existingcustomer.subForm()&quot;>confirm my booking</a>

Any ideas? Thanks.
 
what if you call the function like this?
<a href=&quot;JavaScript:subForm()&quot;>confirm my booking</a>

 
Sorry, the error message that it returns is:

Object doesn't support this property or method

Thanks
 
I just changed the call, to below:

<a href=&quot;JavaScript:subForm()&quot;>confirm my booking</a>

and it appears to work:

<html>

<head>

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
function subForm(){
message = &quot;&quot;
if (document.existingcustomer.Username.value == &quot;&quot;){
message += &quot;\n- Username is blank&quot;
}
if (document.existingcustomer.Credit_Card_Number.value == &quot;&quot;){
message += &quot;\n- Credit Card Number is blank&quot;
}
if (document.existingcustomer.Expiry_Date.value == &quot;&quot;){
message += &quot;\n- Expiry Date is blank&quot;
}
if (document.existingcustomer.Customer_Password.value == &quot;&quot;){
message += &quot;\n- Password is blank&quot;
}
if (message != &quot;&quot;){
alert (&quot;Please correct the following:&quot; + message)
}
else{
document.existingcustomer.action = &quot;bookingconfirmed.php&quot;
document.existingcustomer.method = &quot;post&quot;
document.existingcustomer.submit()
}
}


</script>

</head>

<body>

<form name=&quot;existingcustomer&quot;>

<input type=&quot;text&quot; name=&quot;Username&quot;>
<br><input type=&quot;text&quot; name=&quot;Credit_Card_Number&quot;>
<br><input type=&quot;text&quot; name=&quot;Expiry_Date&quot;>
<br><input type=&quot;text&quot; name=&quot;Customer_Password&quot;>

And this is the link that calls the function:

<a href=&quot;JavaScript:subForm()&quot;>confirm my booking</a>

</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top