Radio Buttons

They have: 7 posts

Joined: Mar 2004

Hi There

I have a radio button that i would like the user to be able to check or uncheck. I need radio buttons other wise i would use checkboxes LOL

Anyway this is what i have come up with

<?php
input type
=\"radio\" onclick=\"this.checked=(this.checked)?false:true\"
?>

This works

But when i add a name or value like this

<?php
<input type=\"radio\" name=\"radiobutton3a\" value=\"Diebold\" onclick=\"this.checked=(this.checked)?false:true\" >
?>

It does not work any ideas please help me i'm going crazy

They have: 5,633 posts

Joined: Jan 1970

when you make the name of 2 radio buttons the same only one can be checked. But if you have diffrent names you can check as many as you wish. With that nifty little code you added you should also be able to un check. But if you want it to work as a check box just make it a check box Laughing out loud

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi redhead,

That is one nice anamoly, nice enough to make me waste a half hour -- to no avail, but a workaround. Smiling It isn't pretty, but you can do it with a global var:

<script type="text/javascript" language="javascript">

var chkIt = 0;

function doit(radObj)
{
radObj.checked = (chkIt) ? 0 : 1;
chkIt = (chkIt) ? 0 : 1;
}
</script>

May I ask why you need to use radios -- users are paranoid about checkboxes???
Laughing out loud
Vinny

Where the world once stood
the blades of grass cut me still

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.