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!

checking 4 different groups of radio buttons..... 1

Status
Not open for further replies.

jamica

Programmer
Apr 25, 2005
17
GB
I have a form with four subjects answerable each with a set of radio buttons.... each line has 5 radio buttons labelled 0, 1,2,3,4. Between the 4 statements the maximum number of points to be allocated is 4.... I need some javascript which can help me to deselect options from the subjects below depending on the options choosen...... ie. if 1 is choosen in the 1st subject all three subjects below need only see radio options 0-3 and not the 4th one.......

Any1 help please....... :(

thanks........
 
deselecting and not seeing will be two different processes.

deselecting could be accomplished using the onclick event. Assign a function to onclick in a button. Put the logic controlling the choices in this function. Use it to set the checked properties for the other buttons.
Code:
...
<input type="radio" ... name="s1" onclick="setOtherButtons();">
...
<script>
function setOtherButtons(){
  if ( document.forms[0].s1[4].checked ) {
    document.forms[0].s2[4].checked = false;
    document.forms[0].s3[4].checked = false;
    document.forms[0].s4[4].checked = false;
  }
}
</script>
The logic may be more complex but these are the essential ingredients.


hiding the options could be accomplished using the style object and a <div> tag. This is a bit elaborate to code. Here is a tutorial

 
Hi i now have

<html> function spots {

var = optionNum
var = val

document.forms.getelementbyname("ol_" + optionNum + "_" + val )

spotsAvail[0] = 4;
spotsAvail[1] = 4;
spotsAvail[2] = 4;
spotsAvail[3] = 4;

workOutSpotsAvail {



}


greyOut {

document.forms[0].r4.disabled = true

}
}
</html>

and

<html>

<input type="radio" name="o1" id="o1_1" value="1" class="check1" onclick="workOutSpotaAvail(1, 1)" />
<input type="radio" name="o1" id="o1_2" value="2" class="check2" onclick="workOutSpotaAvail(1, 2)" />
<input type="radio" name="o1" id="o1_3" value="3" class="check3" onclick="workOutSpotaAvail(1, 3)" />
<input type="radio" name="o1" id="o1_4" value="4" class="check4" onclick="workOutSpotaAvail(1, 4)" />
<br />

<input type="radio" name="o2" id="o2_1" value="1" class="check1" onclick="workOutSpotaAvail(2, 1)" />
<input type="radio" name="o2" id="o2_2" value="2" class="check2" onclick="workOutSpotaAvail(2, 2)" />
<input type="radio" name="o2" id="o2_3" value="3" class="check3" onclick="workOutSpotaAvail(2, 3)" />
<input type="radio" name="o2" id="o2_4" value="4" class="check4" onclick="workOutSpotaAvail(2, 4)" />
<br />

<input type="radio" name="o3" id="o3_1" value="1" class="check1" onclick="workOutSpotaAvail(3, 1)" />
<input type="radio" name="o3" id="o3_2" value="2" class="check2" onclick="workOutSpotaAvail(3, 2)" />
<input type="radio" name="o3" id="o3_3" value="3" class="check3" onclick="workOutSpotaAvail(3, 3)" />
<input type="radio" name="o3" id="o3_4" value="4" class="check4" onclick="workOutSpotaAvail(3, 4)" />
<br />

<input type="radio" name="o4" id="o4_1" value="1" class="check1" onclick="workOutSpotaAvail(4, 1)" />
<input type="radio" name="o4" id="o4_2" value="2" class="check2" onclick="workOutSpotaAvail(4, 2)" />
<input type="radio" name="o4" id="o4_3" value="3" class="check3" onclick="workOutSpotaAvail(4, 3)" />
<input type="radio" name="o4" id="o4_4" value="4" class="check4" onclick="workOutSpotaAvail(4, 4)" />

</html>

i need to b able to make the javascript run so that the user can not select a total higher than 4 in the combined set of 4 radio groups.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top