javascript - JQuery select dropdowns by id using AND and OR operators combination -


 $(document).ready(function(){             if(       $("#disaster_1,#genre_id_1,#area_id_1").change("background-color", "yellow"))      {      alert("threee changed");      }      else{        $("#disaster_1,#genre_id_1").css("background-color", "red");      }      });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>                       <h1>welcome web page</h1>      <h2>nice meet you</h2>            <div>very nice indeed.</div>            <p>how you?</p>      <p>i'm fine, <span>thanks.</span></p>                    <select name="area_id[1]" id="area_id_1" class="adminclass">                  <option value="0" disabled selected>select area...</option>                  <option value="1" >talluk</option>                  <option value="2" >district</option>                  <option value="3" >village</option>              </select>              <select name="genre_id[1]" id="genre_id_1" class="thematicclass">                  <option value="0" disabled selected>select genre...</option>                  <option value="1" >thematic</option>                  <option value="2" >forest</option>                  <option value="3" >lulc</option>              </select>                <select name="disas_id[1]" id="disaster_1" class="diasterclass">                  <option value="0" disabled selected>select genre...</option>                  <option value="1" >flood</option>                  <option value="2" >cyclone</option>                  <option value="3" >earthquake</option>              </select>

based on selection of id or classname combinations required ( when select 3 combination alert 1 functionality,when select 2 combinations alert functionality or call method , when select single select alert functionality) example. suppose example on select of adminclass,thematicclass , disasterclass 3 combination alert has come if suppose select of admin , disasterclass combiation alert function call display admin , disaster selected likewise combinations has come.

example worked out

$('#wrappers && #select1').change(function(){        alert("two chages");        if ($(this).val() === "0") {          $('#select1').attr('disabled', true);          $('#select2').attr('disabled', true);        } else {          $('#select1').attr('disabled', false);          $('#select2').attr('disabled', false);        }      });      $('#wrappers && #select1 && #select2').change(function(){        alert("three chages");        if ($(this).val() === "0") {          $('#select1').attr('disabled', true);          $('#select2').attr('disabled', true);        } else {          $('#select1').attr('disabled', false);          $('#select2').attr('disabled', false);        }      });
article, aside, figure, footer, header, hgroup,         menu, nav, section { display: block; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>  <select id="wrappers">          <option value="1">district</option>          <option value="0">taluk</option>        </select>      <select id="select1">            <option value="foo">foo</option>          <option value="bar">bar</option>          </select>      <select id="select2">            <option value="foo">foo</option>          <option value="bar">bar</option>          </select>

  1. workout 2 code

 $('#disaster_1,area_id_1').change(populateattrsdropdowns);   $('#disaster_1,area_id_1,admin_id_1').change(thrreef);              function populateattrsdropdowns()    {       alert("two selected");   }   function thrreef()    {       alert("three selected");   }
 <!doctype html>      <html lang="en">         <head>            <meta charset="utf-8">            <title>change demo</title>            <style>               div {                   color: red;               }            </style>            <script src="https://code.jquery.com/jquery-1.10.2.js"></script>         </head>         <body>            <select name="sweets" id="admin_id_1">               <option>chocolate</option>               <option>candy</option>               <option>taffy</option>               <option>caramel</option>               <option>fudge</option>               <option>cookie</option>            </select>            <select name="area_id[1]" id="area_id_1" class="area">               <option value="0" disabled selected>select area...</option>               <option value="1" >talluk</option>               <option value="2" >district</option>               <option value="3" >village</option>            </select>            <select name="disas_id[1]" id="disaster_1" class="diasterclass">               <option value="0" disabled selected>select genre...</option>               <option value="1" >flood</option>               <option value="2" >cyclone</option>               <option value="3" >earthquake</option>            </select>            <div></div>                 </body>  </html>


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -