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.
djdd87
68.7k29 gold badges160 silver badges198 bronze badges
asked Sep 2, 2010 at 12:50
Alex Pliutau
22k28 gold badges116 silver badges144 bronze badges
-
show some concise version of the codeBozho– Bozho2010年09月02日 12:52:23 +00:00Commented Sep 2, 2010 at 12:52
3 Answers 3
If you give the form an "id" you can:
var form = document.getElementById('yourIdValue');
form.mySubmit.click();
answered Sep 2, 2010 at 12:51
Pointy
415k62 gold badges600 silver badges633 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Marcel Korpel
Now you
click on the form? Will that submit it? I'd use the submit method.better yet you can just use the submit method. no need for the button.
var currForm = document.getElementById('yourIdValue');
currForm.submit();
answered Sep 2, 2010 at 12:56
Guy Schaller
4,7104 gold badges35 silver badges55 bronze badges
Comments
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();
}
);
answered Sep 2, 2010 at 12:58
Pramendra Gupta
14.9k4 gold badges35 silver badges35 bronze badges
Comments
lang-js