简体   繁体   English

html / javascript / php运行脚本onclick复选框

[英]html/javascript/php run script onclick checkbox

This should be a very easy thing to do but I can't find a good reference on how to do it. 这应该是一件非常容易的事情,但我找不到如何做的好参考。

I want to submit a form upon clicking a checkbox. 我想在点击复选框后提交表单。 To make it a one click process and save user the step of clicking the check box and then clicking form submit, I'd like the form to be submitted upon clicking the checkbox. 要使其成为一键式处理并保存用户单击复选框然后单击表单提交的步骤,我希望单击复选框时提交表单。

My question is do I need to call a javascript function to do this or can html do this natively? 我的问题是我需要调用javascript函数来执行此操作还是html可以本机执行此操作?

<form action="post.php" method="post"><input type="checkbox" name="done" id="done" value="1" onclick="post.php"></input></form>

doesn't seem to work. 似乎不起作用。 Do I have to call a javascript function, or am I missing something simple. 我是否必须调用javascript函数,或者我错过了一些简单的东西。 Thanks 谢谢

Try to replace 尝试更换

onclick="post.php"

By 通过

onclick="submit();"

尝试onclick="this.parentNode.submit()"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM