Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

disabling specific radio buttons

Status
Not open for further replies.

PushCode

Programmer
Joined
Dec 17, 2003
Messages
573
Location
US
I have a form with two groups of radio buttons. Let's call them the left and right groups. When the user clicks on a certain radio button from the left group (the one with the value of '5', all radio buttons in the right group are disabled. I have this part working. What I need to do though is disable all radio buttons in the right group with the exception of the radio button with the value of '9'.

Can anyone help me modify my js to handle this? Thanks!

Code:
Left group...
<input type="radio" id="pkg#qGet_pkgs.pkg_id#" name="pkg_name" value="#qGet_pkgs.pkg_id#" onclick="toggleGroup(this.form.prog_name, this)">

Right group...
<input type="radio" id="prog#qGet_prog.prog_id#" name="prog_name" value="#qGet_prog.prog_id#">

JS...
function toggleGroup(obj, src) {
    var val = src.checked && (src.value=='5');
    for (var i = 0; i < obj.length; i++) {
        obj[i].disabled = val;
		obj[i].checked = false;
    }

Thanks again!
 
Ummm.... is this what you're wanting?
Code:
function toggleGroup(obj, src) {
    var val = src.checked && (src.value=='5');
    for (var i = 0; i < obj.length; i++) {
        [!]if (obj[i].value != 9) {[/!]
            obj[i].disabled = val;
            obj[i].checked = false;
        [!]}[/!]
    }
}

-kaht

Looking for a puppy?

silky-icon-left.gif
[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
silky-icon-right.gif
 
Yes, that's exactly it. Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top