dongyu9667 2013-01-23 02:49
浏览 56
已采纳

如何在不提交复选框的情况下获取复选框值?

I have a checkbox like so..

<form action='index.php' method='post'>
    <input type='checkbox' name='checkme' value='Yes' /> 
    Include Inactive Keys 
</form>

I also have a submit button on the very bottom of the web-page. But when I hit the submit button, I want it to also grab the value of the checkbox (whether it was clicked or not). How can I grab the value?

  • 写回答

3条回答 默认 最新

  • dongzhila3786 2013-01-23 02:58
    关注

    If you want to see the value of the checkboxes item before submitting it can be accomplish via javascript or jquery.

    You can get the value of the checkboxes item by document.getElementsByName("checkme")[0].

    But still you'll have difficulty in getting the checkboxes value upon submission of the form unless you're processing the submission on the same page.

    If you process the form submission in the same page you can use the code above to get the value of each checkboxes even those not checked.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器