javascript - Find out which of three Select boxes is used -


i have 3 three select fields 1 entity attribute. picture below shows (fiddle).enter image description here

i trying find way detect of select fields has been used (which last 1 user clicked on) , (alert it) number of select box (0, 1, 2) , value selected.

the aim of code tell server side of select boxes needs consider when saving form. send data via ajax (which know how to, need part figure out of select box has been used)

<div class="form-group"> <label class="col-sm-2 control-label control-label required">contenu de l'annonce</label> <div class="col-sm-10 form-inline">  <select id="_d1_h1"> <option value="" disabled="" selected="" hidden="">label1</option> <option value="value1d">value1d</option> <option value="value2">value2</option> <option value="value3">value3</option> </select>  <select id="d1_h2"> <option value="" disabled="" selected="" hidden="">label2</option> <option value="value4">value4</option> <option value="value5">value5</option> </select>  <select id="d1_h3"> <option value="" disabled="" selected="" hidden="">label3</option> <option value="value6">value6</option> </select>  </div>  </div> 

$('.drp').change(function() {   let selecteddropdown = $(this).attr('id');   let selectedvalue = $(this).val();   alert(selecteddropdown);   alert(selectedvalue);  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>  <div class="form-group">      <label class="col-sm-2 control-label control-label required">contenu de l'annonce</label>      <div class="col-sm-10 form-inline">            <select class="drp" id="_d1_h1">  <option value="" disabled="" selected="" hidden="">label1</option>  <option value="value1d">value1d</option>  <option value="value2">value2</option>  <option value="value3">value3</option>  </select>            <select class="drp" id="d1_h2">  <option value="" disabled="" selected="" hidden="">label2</option>  <option value="value4">value4</option>  <option value="value5">value5</option>  </select>            <select class="drp" id="d1_h3">  <option value="" disabled="" selected="" hidden="">label3</option>  <option value="value6">value6</option>  </select>        </div>  </div>


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -