Link to home
Start Free TrialLog in
Avatar of Pete Winter
Pete WinterFlag for United Kingdom of Great Britain and Northern Ireland

asked on

show table row if select menu equals 1

I have previously used the javascript code below to show / hide a table based a check box:

<script language="javascript">
      $("document").ready(function() {
            if (!$("#phone_support").attr('checked')) $(".captionRow").show();
            $("#phone_support").click(function(){
                  if ($("#phone_support").attr('checked')) $(".captionRow").hide();
                  else $(".captionRow").show();
                  })
            });
</script>

How do I change it so the captionRow class only shows if the value of the below select menu is 1?

<select name="ink_brand_id" id="ink_brand_id">
        <?php
do {  
?>
        <option value="<?php echo $row_rs_ink_brand['id']?>"><?php echo $row_rs_ink_brand['ink_brand']?></option>
        <?php
} while ($row_rs_ink_brand = mysql_fetch_assoc($rs_ink_brand));
  $rows = mysql_num_rows($rs_ink_brand);
  if($rows > 0) {
      mysql_data_seek($rs_ink_brand, 0);
        $row_rs_ink_brand = mysql_fetch_assoc($rs_ink_brand);
  }
?>
      </select>
Avatar of hielo
hielo
Flag of Wallis and Futuna image

try:
if( $('#ink_brand_id option:selected').attr('value')==1 )$(".captionRow").show();
Avatar of Pete Winter

ASKER

Thanks, but it's not working for me. Can you please check:

<script language="javascript">
      $("document").ready(function() {
                  if( $('#ink_brand_id option:selected').attr('value')==1 )$(".captionRow").show();
            $('#ink_brand_id option:selected').click(function(){
                  if( $('#ink_brand_id option:selected').attr('value')!=1 )$(".captionRow").hide();
                  else $(".captionRow").show();
                  })
            });
</script>
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
Perfect. Many thanks for your help!