如何使onclick函数提交表单并执行操作? [英] How to make an onclick function submit a form and do it's action?
本文介绍了如何使onclick函数提交表单并执行操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< style>
#myiframe {
position:absolute;
display:none; }
< / style>
< script>
函数myFunctionExecuteForm()
{
//(执行表单的动作)
}
< / script>
< div onclick =myFunctionExecuteForm()>保存< / div> //分区
< / form>
感谢您的帮助! :D
解决方案
使用
document.forms [search]。submit();
My plan is to have a division that has an onclick event that will pass a form. Note that the division is not part of the form, instead, I want to make an onclick function that would execute the form action and put it on a target (which is an iframe, by the way). My code goes like this:
<style>
#myiframe {
position: absolute;
display:none; }
</style>
<script>
function myFunctionExecuteForm()
{
//(execute the action of the form here)
}
</script>
<iframe id="myframe" name="carsearch" scrolling="no" frameborder = "0" style = "position:absolute;top:42px; left:287px; width:723px; height:528px;"></iframe>
<div onclick="myFunctionExecuteForm()">Save</div> //The division
<form name="search" id="search" method="get" action="/crime_map/map_crime.php" target="carsearch">
</form>
Thanks for your help! :D
解决方案
Do it using
document.forms["search"].submit();
这篇关于如何使onclick函数提交表单并执行操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文