0

Hi i have a combobox like this:

<select name="tayuda" id="mySelect">
 <option value="" selected>Seleccionar</option>             
 <option value="Denuncia" <?=($info['tayuda']=='Denuncia')?'selected':''?>>Denuncia</option>
 <option value="Reclamo" <?=($info['tayuda']=='Reclamo')?'selected':''?>>Reclamo</option>
 <option value="Consulta" <?=($info['tayuda']=='Consulta')?'selected':''?>>Consulta</option>
 <option value="Otro" <?=($info['tayuda']=='Otro')?'selected':''?>>Otro</option>
</select>

and i want to hide 3 fieldsets if option value="Consulta" is selected or if there is no selection.

how can i get it work?

user995691
  • 89
  • 1
  • 3
  • 13

3 Answers3

0

Implement on change event on select control. There check for value and if value is COnsulta or empty, hide fielsets (set their css visibility atribute to hidden).

elrado
  • 4,960
  • 1
  • 17
  • 15
0

maybe something like this ?

  function hideField(){
    var e = document.getElementById("mySelect");
     var strUser = e.options[e.selectedIndex].value;

     if( strUser == 'Consulta' ) {
        $("#fieldset1").hide();
        $("#fieldset2").hide();
        $("#fieldset3").hide();
     }
     else if( strUser == '' ) {
        $("#fieldset1").hide();
        $("#fieldset2").hide();
        $("#fieldset3").hide();
     }

  }
Maxim VA
  • 370
  • 1
  • 3
  • 16
0

You may have a look here

JQuery Hide Div when Option is Selected

Would require minor modifications.

jQuery(document).ready(function() {
   jQuery("#mySelect").change(function() {
      var opt-selected = jQuery(this).find("option:selected").val()
      if(opt-selected == "Consulta" || opt-selected == "") {
         jQuery("fieldset.multiples").hide();
      } else {
         jQuery("fieldset.multiples").show();
      }

   });
});

Might need some css

.multiples {
  display: none;
}
Community
  • 1
  • 1
swapab
  • 2,402
  • 1
  • 27
  • 44