tags:

views:

81

answers:

2

This is the javascript code im using.

<script language="javascript" type="text/javascript">
function cancelevent()
    {
     input_box=confirm("Are you sure you want to cancel?");
     if (input_box==true) {
      document.cancelevent.submit();
     } else {
     }

    }
</script>

This is the form thats being submitted:

<form name=cancelevent method="post" action="whor.php">
<input type="hidden" name="owner" value="owner">
<a href="javascript:cancelevent()">Cancel</a>
</form>

I have this form on 2 different pages. One page it works, the other, i get this error

Error: document.cancelevent.submit is not a function

Ive literally copy and pasted the code from the working page to the 2nd page....no idea what is going on or why it would do this.

+5  A: 

Put an id on your form

<form id="cancelEventForm" name=cancelevent method="post" action="whor.php">

And use

document.getElementById('cancelEventForm').submit();
Zoidberg
+5  A: 

I think the problem is that the HTML form and the javascript function have the same name!

Vinz