How do I achieve this in jQuery?

Could anyone please help me with this code?



    Categoria utente (User category)   
    <select class="operators" id="operators02">
      <option value="client" selected>Persona (Client)</option>
      <option value="association">Associazione convenzionata (Association)</option>
      <option value="vendor">Partner fornitore (Vendor)</option>
    </select>&nbsp;&nbsp;&nbsp;
    
    <select class="operatoroptions" id="operatoroptionss02">
      <option value="and">e (and)</option>
      <option value="or">o (or)</option>
      <option value="not">non (not)</option>
    </select> 
    <br>
    <br>


    <span class="associazioneapparteneneza">
        Nome associazione (Name of User's Association)&nbsp;&nbsp;&nbsp;
        <select class="operators" id="operators03A">
          <option value="contains">contiene (contains)</option>
          <option value="doesnotcontain">non contiene (does not contain)</option>
          <option value="equalto">uguale a (equal to)</option>
          <option value="notequalto">non uguale a(not equal to)</option>
        </select>&nbsp;&nbsp;&nbsp;
    
        <input id="input_UserAssociationName"></input>&nbsp;&nbsp;&nbsp;
    
        <select class="operatoroptions" id="operatoroptionss03A">
          <option value="and">e (and)</option>
          <option value="or">o (or)</option>
          <option value="not">non (not)</option>
        </select>
    </span> 

    <span class="nomeattivita nomeassociazione">
        Nome Associazione Convenzionata (Name of Association)&nbsp;&nbsp;&nbsp;
        <select class="operators" id="operators03B">
          <option value="contains">contiene (contains)</option>
          <option value="doesnotcontain">non contiene (does not contain)</option>
          <option value="equalto">uguale a (equal to)</option>
          <option value="notequalto">non uguale a(not equal to)</option>
        </select>&nbsp;&nbsp;&nbsp;
    
        <input id="input_AssociationName"></input>&nbsp;&nbsp;&nbsp;
    
        <select class="operatoroptions" id="operatoroptionss03B">
          <option value="and">e (and)</option>
          <option value="or">o (or)</option>
          <option value="not">non (not)</option>
        </select>
    </span> 

    <span class="nomeattivita ragionesociale">
        Ragione sociale (Business name)&nbsp;&nbsp;&nbsp;
        <select class="operators" id="operators03C">
          <option value="contains">contiene (contains)</option>
          <option value="doesnotcontain">non contiene (does not contain)</option>
          <option value="equalto">uguale a (equal to)</option>
          <option value="notequalto">non uguale a(not equal to)</option>
        </select>&nbsp;&nbsp;&nbsp;
    
        <input id="input_BusinessName"></input>&nbsp;&nbsp;&nbsp;
    
        <select class="operatoroptions" id="operatoroptionss03C">
          <option value="and">e (and)</option>
          <option value="or">o (or)</option>
          <option value="not">non (not)</option>
        </select>
    </span> 

Open in new window




In #operators02

if I select option "client" then span.associazioneapparteneneza should become visible and span.nomeattivita should be hidden

if I select option "association" then span.associazioneapparteneneza and span.ragionesociale should hide and span.nomeassociazione should be visible

if I select option "vendor" then span.associazioneapparteneneza and span.nomeassociazione should hide and span.ragionesociale should be visible


I would like jQuery to achieve this.

thanks in advance
badwolfffAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Try:
$(function(){
   $('#operators02').on('change',function(){
      var val = $('option:selected',this).val();
      if( 'client'==val)
      {
           $('span.nomeattivita').hide();
           $('span.associazioneapparteneneza').show();
      }
      else if('association'==val)
      {
            span.associazioneapparteneneza and span.ragionesociale should hide and 
           $('span.associazioneapparteneneza').hide();
           $('span.ragionesociale').hide();
           $('span.nomeassociazione').show();
      }
      else if( 'vendor'==val)
      {
           $('span.associazioneapparteneneza').hide();
           $('span.nomeassociazione').hide();
           $('span.ragionesociale').show();
      }
   });
});

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.