Link to home
Start Free TrialLog in
Avatar of D J
D JFlag for United States of America

asked on

ColdFusion How to disable "All" in Drop down when radio button is selected

How can I disable "All" in my drop down when the user selects a radio button in a query?

I.E. Make the user select an option in the drop down, when a radio button is selected.

Radio code:
<input type="radio" name="showall" id="showall" value="1" />

Open in new window

     
Drop down code:
<select name="discipline1" style=width:170px;>
        <option value="ALL">ALL</option>
        <cfoutput query="DropDown1">
          <option value="#DropDown1.ship#">#DropDown1.ship#</option>
        </cfoutput>
    	</select>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America 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
with jquery you can do it like this:

$("#showall").click(function() {
      var i = $(this).val();
    alert(i);
     if (i == '1') {
         var selectAll = $("#discipline1 option:first").val();
         if ($.trim(selectAll) == 'ALL') {
            $("#discipline1 option:first").attr('disabled', true);
      }
     }
});¿

<input type="radio" name="showall" id="showall" value="1" />
<select name="discipline1" id="discipline1" style=width:170px;>
    <option value="ALL">ALL</option>
        <option value="2">2</option>
    <option value="3">3</option>
        </select>¿

Check this:

http://jsfiddle.net/NpNFh/6/

1.

Make the user select an option in the drop down, when a radio button is selected.

2.

How to disable "All" in Drop down when radio button is selected
Hm.. those are 2 different things.  Which one do you need? If it's 1, try my example. If it's 2, try myselfrandhawa's.
Avatar of D J

ASKER

Thanks _agx_ for sharing your knowledge.