Jump to content

block/show form element based on previous choice


learningcurve

Recommended Posts

I know this can be done, but I just can't write the javascript correctly to make it work.  

I have these two form elements:

<input type="radio" name="JECT" value="no" checked <?php if(@$JECT=="no"){ echo "checked";}?>>
No thanks</br>

<input type='radio' name='JECT' value='JECTindividual_print' <?php if(@$JECT=="JECTindividual_print"){ echo "checked";}?>>
Print subscription (US and Canada only): US $<?php echo $JECTindividual_print_price['base']['United States']; ?>, Canada $<?php echo $JECTindividual_print_price['base']['Canada']; ?></br>

<input type='radio' name='JECT' value='JECTindividual_electronic' <?php if(@$JECT=="JECTindividual_electronic"){ echo "checked";}?>>
Electronic subscription (access to complete online archive): $<?php echo $JECTindividual_electronic_price['base']; ?></br>

<input type='radio' name='JECT' value='JECTindividual_combo' <?php if(@$JECT=="JECTindividual_combo"){ echo "checked";}?>>
Combination print and electronic subscription (US and Canada only): $<?php echo $JECTindividual_combo_price['base']; ?></br>

        <p style="text-indent:30px;">Length of subscription:</br></p>
            <label><input type="radio" name="JECTsub" value="1" checked <?php if(@$JECTsub=="1"){ echo "checked";}?>> 1 year</label></br>
            <label><input type="radio" name="JECTsub" value="2" <?php if(@$JECTsub=="2"){ echo "checked";}?>> 2 years</label></br>
            <label><input type="radio" name="JECTsub" value="3" <?php if(@$JECTsub=="3"){ echo "checked";}?>> 3 years</label></br>
            <label><input type='checkbox' name='JECTrenewal' value='yes' <?php if(@$JECTrenewal=="yes"){ echo "checked";}?>> Check box if this is a renewal</label></br>
    

If the "no" radio button is checked (in other words, if $JECT="no", I want the JECTsub radio buttons to not show.  if any other value is chosen for JECT, I want the JECTsub buttons to show.  Thanks ahead for the help. 

 

why would you give all the radio buttons the same name? especialy if they don't have an id to make them uniquely identifiable.  I suggest fixing that first, and then apply a class to the radio buttons that you want to selectivly show then just change the display of this class using javascript to suit.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.