使用复选框提交表单 [英] submit a form using checkbox
本文介绍了使用复选框提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个非常简单的问题 - 当我更改复选框的状态时,如何获取表单提交
以下是我的代码
< form name =formNameid =formNameaction =<?php echo $ _SERVER ['PHP_SELF'];?> ;方法= GET >
< input type =checkboxname =categories1value =1onClick =submit();> 1< / input>
< / form>
除了submit()我已经试过了:
$ b $
但这些都不起作用。当我检查或取消选中框时什么也没有发生
任何线索?
解决方案
引用表单名称属性:
document.formName.submit()
I have a very simple question - how do I get a form to submit when I change the status of a checkbox
Here is my code
<form name="formName" id="formName" action="<?php echo $_SERVER['PHP_SELF'];?>" method="get">
<input type ="checkbox" name="categories1" value = "1" onClick="submit();">1</input>
</form>
in addition to submit() I have tried:
- this.form.submit()
- document.getElementById('formName').submit()
- this.parentNode.submit()
but none of these work. When I check or uncheck the box nothing happen
any clues?
解决方案
Refer to the form name attribute:
document.formName.submit()
这篇关于使用复选框提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文