Link to home
Start Free TrialLog in
Avatar of cempasha
cempasha

asked on

form - radio button check - javascript

Hi all,
I have a form with 2 different radio elements. First radio button is a yes no question. if yes selected nothing happens, however if no is selected, other radio button is activated (has 4 radio buttons should be selected). My question is, I can initially select a value on this field however if I click on yes (on the first radio button) and click on no (again in the first radio button) it doesnt select any value automatically. Is it possible to select a value everytime no is clicked on the first radio button? thanks in advance
Avatar of hielo
hielo
Flag of Wallis and Futuna image

This makes no sense:
>>... other radio button is activated (has 4 radio buttons should be selected).
radio buttons are mutually exclusive. It seems you are using the term radio button for select lists, radio buttons and checkboxes interchangeably. These are different elements and actually make a difference when it comes to programming. Clarify or better yet, post the code that you have.
Avatar of cempasha
cempasha

ASKER

I've attached a working example. You can try this one and see what I'm trying to do. I hope this helps
<SCRIPT LANGUAGE="JavaScript">
 
function Disab (val) {
if(val=="1")
{
theForm.gr12[0].disabled=true;theForm.gr12[0].checked=false;
theForm.gr12[1].disabled=true;theForm.gr12[1].checked=false;
theForm.gr12[2].disabled=true;theForm.gr12[2].checked=false;
theForm.gr12[3].disabled=true;theForm.gr12[3].checked=false}
 
 
if(val=="2")
{
theForm.gr12[0].disabled=false;
theForm.gr12[1].disabled=false;
theForm.gr12[2].disabled=false;
theForm.gr12[3].disabled=false}
}
</SCRIPT>
 
 
<form name="theForm"> 
<input type="radio" name="gr1" value="1" onClick="Disab(1)">
                                  Yes
                                  <input name="gr1" type="radio" onClick="Disab(2)" value="0">
<table> 
 <tr>
                                <td><label style="color: rgb(102, 102, 102);" id="lblInternetLink1" for="fkInternetLink1">link1 </td>
                                <td><input type="radio" name="gr12" value="1" disabled></td>
                              </tr>
                              <tr>
                                <td><label style="color: rgb(102, 102, 102);" id="lblInternetLink2" for="fkInternetLink2">link2**</td>
                                <td><input type="radio" name="gr12" value="2" disabled checked></td>
                              </tr>
                              <tr>
                                <td><label style="color: rgb(102, 102, 102);" id="lblInternetLink3" for="fkInternetLink3">link3*</td>
                                <td><input type="radio" name="gr12" value="3" disabled></td>
                              </tr>
                              <tr>
                                <td><label style="color: rgb(102, 102, 102);" id="lblInternetLink4" for="fkInternetLink4">link4</td>
                                <td><input type="radio" name="gr12" value="4" disabled></td>
                              </tr>
</table>
</form> 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
one word for you.
perfect
thanks very much :)