简体   繁体   English

单选按钮返回 false onclick

[英]radio button return false onclick

I have this form here and want each radio buttons not to be able to be checked.我在这里有这个表格,希望每个单选按钮都不能被选中。 I dont want disabled because if one happens to be selected I still want that value to be submitted to the database.我不想禁用,因为如果碰巧选择了一个,我仍然希望将该值提交到数据库。 This is just a basic example.这只是一个基本的例子。

When I click on one of them it checks, then does not allow me to click the other one.当我单击其中一个时,它会检查,然后不允许我单击另一个。 I want both buttons not to be able to be checked.我希望两个按钮都不能被检查。

 <form action="here.php" method="post"> 
    <input onclick="return false" type="radio"  name="firstone" value="Yes"    /> Yes 
    <input  onclick="return false" type="radio" name="firstone" value="No"   /> No
    <input type="submit"  /> 
    </form>

Does anyone know how to fix this?有谁知道如何解决这一问题? I dont want to use javascript.我不想使用 javascript。

The only reason I can imagine you want to have them disabled, but not 'disabled' is because they look ugly when they're disabled.我能想象你想让它们禁用而不是“禁用”的唯一原因是因为它们在禁用时看起来很丑。

How about you just change the CSS on the page?您只需更改页面上的 CSS 怎么样?

:disabled CSS selector :禁用 CSS 选择器

Rather than trying to prevent clicking on radio buttons.而不是试图阻止单击单选按钮。 You should use a hidden element to contain the values to send with your form.您应该使用隐藏元素来包含要与表单一起发送的值。

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

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