0

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.

3
  • Yeah, and "owner".... tsk tsk Commented Dec 18, 2009 at 13:37
  • 1
    And a mixture of quoted and unquoted attribute values... agh my eyes! Commented Dec 18, 2009 at 13:45
  • its complicated lol, pulled from php Commented Dec 18, 2009 at 13:49

2 Answers 2

7

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

Sign up to request clarification or add additional context in comments.

Comments

5

Put an id on your form

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

And use

document.getElementById('cancelEventForm').submit();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.