[英]How to make an onclick function submit a form and do it's action?
我的计划是让一个部门具有一个将通过表单的onclick事件。 请注意,该划分不是表单的一部分,相反,我想创建一个onclick函数,该函数将执行表单操作并将其放在目标(顺便说一下,这是一个iframe)上。 我的代码是这样的:
<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>
谢谢你的帮助! :d
使用它
document.forms["search"].submit();
在点击功能上使用jQuery,例如以下代码
jQuery('id/class of submitbutton').on('click',function(){
----your code here ------
}
或使用此html
<form name="search" onsubmit="return function_name();" id="search" method="get" action="/crime_map/map_crime.php" target="carsearch">
我会给div一个ID或一个类,但是下面应该可以
$( "div" ).click(function() {
$( "#search" ).submit();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.