dimanche 24 janvier 2021

Convert javascript of checkbox to select type

Earlier the code for the checkbox was

<li class="list-group-item">
       <div class="form-check">
        <label class="form-check-label">
          <input type="checkbox" class="form-check-input common_check" value="<?= $row['Year']; ?>" id="Year"><?= $row['Year'];  ?>
        </label>
       </div>
  </li>

and js for this to get the filtered text was

function get_filter(text_id)
{
  var filterData = [];
  $('#'+text_id+':checked').each(function(){
     filterData.push($(this).val());
   });
  return filterData;
}

Now if I want to turn this to select option menu bar

<option class="common_check" value="<?= $row['Year']; ?>" id="Year"><?= $row['Year'];  ?>

So what should be the javascript for this??




Aucun commentaire:

Enregistrer un commentaire