简体   繁体   中英

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.

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?

:disabled CSS selector

Rather than trying to prevent clicking on radio buttons. You should use a hidden element to contain the values to send with your form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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