As title says, is there a way to send form
when element outside of form is clicked? Plus, is it available without using form
associate开发者_如何学Cd (button
/input
etc.) elements?
As example, can form
be submitted when div
is clicked?
Sure:
<form name="myForm" action="" method="post">
<!-- form inputs go here -->
</form>
<div id="formSubmit"></div>
<script type="text/javascript">
var myForm = document.forms['myForm'];
var formSubmit = document.getElementById('formSubmit');
formSubmit.onclick = function(){
myForm.submit();
}
</script>
document.getElementById("formName").submit();
To submit the form, you can call form.submit()
.
Sure, assign an id to that form.
Once you click the desired element (button/input/div) you can do somthing like this in javascript
$("#YourFormId").submit();
精彩评论