0

I have the next code:

document.myForm.mySubmit.click();

Where myForm - form name, mySubmit - submit name. I want to call submit of my form outside me form. My problem - my form doesn't have names(terrible?). How can I do this with help of id or classes?

Or may be you know another way?

Thank you.

1
  • show some concise version of the code Commented Sep 2, 2010 at 12:52

3 Answers 3

2

If you give the form an "id" you can:

 var form = document.getElementById('yourIdValue');
 form.mySubmit.click();
Sign up to request clarification or add additional context in comments.

1 Comment

Now you click on the form? Will that submit it? I'd use the submit method.
1

better yet you can just use the submit method. no need for the button.

var currForm = document.getElementById('yourIdValue');
currForm.submit();

Comments

0

Here is an example

$('#my_button').click(
    function()
    {
        $('#my_form').trigger('onsubmit');
        // Or 
        $('#my_form').onsubmit();
       // or 
        $('#my_form').trigger('onSubmit');
       // or  even --
        $('#my_form').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.