当复选框被选中时提交表单 [英] submitting a form when a checkbox is checked
本文介绍了当复选框被选中时提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在选中复选框时提交表单?
is there are way to submit a form when a checkbox is checked?
<form id="formName" action="<?php echo $_SERVER['PHP_SELF'];?>" method="get">
<input type ="checkbox" name="cBox[]" value = "3">3</input>
<input type ="checkbox" name="cBox[]" value = "4">4</input>
<input type ="checkbox" name="cBox[]" value = "5">5</input>
<input type="submit" name="submit" value="Search" />
</form>
<?php
if(isset($_GET['submit'])){
include 'displayResults.php';
}
?>
这是我目前的状态,但我想提交表单而不提交按钮,用户选中或取消选中复选框。任何帮助?
That is what I have currently, but I would like to submit the form without a submit button, when the user checks or unchecks a checkbox. Any help?
推荐答案
在纯JavaScript中简单地放置
In plain JavaScript simply put
onChange="this.form.submit()"
/ input标签。
into the form/input tag.
这篇关于当复选框被选中时提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文