houssam_ballout Posted May 3, 2011 Share Posted May 3, 2011 Hello,I need help with this:2 radio button and 2 text boxes, say them R1, T1, R2, T2when I select R1 then T1 is enabled , and T2 is disabled. when I select R2, then T1 is disable and T2 is enabled.Only, R1 or R2 can be selected (so giving them one name)Any help?Thanks in advance Link to comment Share on other sites More sharing options...
ShadowMage Posted May 3, 2011 Share Posted May 3, 2011 I'd write a function that accepts three parameters. One being a reference to the radio being checked, the other two being id's for the elements that need toggling. Then inside the function, check to see if the radio is checked and if it is perform the appropriate actions (enabling/disabling the textboxes).I'll define the function for you and show you how to assign it to the onclick handler of your radios, but I'll leave the guts of the function up to you to try first. function toggleTextBox(elem, txtOne, txtTwo) { //elem is the reference to the radio button being clicked //txtOne and txtTwo will be the text boxes you need to toggle} And assign it like so:<input type='radio' name='aRadio' onclick="toggleTextBox(this, 'txtBoxA', 'txtBoxB');" />The keyword this passes a reference to the radio button to the function. Link to comment Share on other sites More sharing options...
jeffman Posted May 3, 2011 Share Posted May 3, 2011 Make sure you know the difference between disabled and readonly. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.