jeudi 27 août 2020

I want to get result of each checkbox in PHP POST by ajax on real time checkbox selection

I want to get result of each checkbox in PHP POST by ajax on real time checkbox selection

function showValues() {
  var str = $("form").serialize();
  $("#results").text(str);
}
$("input[type='checkbox']").on("click", showValues);
showValues();
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>

<form>
  <input type="checkbox" name="check" value="check1" id="ch1">
  <label for="ch1">check1</label>
  <input type="checkbox" name="check" value="check2" id="ch2">
  <label for="ch2">check2</label>
  <input type="checkbox" name="check" value="check3" id="ch3">
  <label for="ch2">check3</label>
  <input type="checkbox" name="check" value="check4" id="ch4">
  <label for="ch2">check4</label>
  <input type="checkbox" name="check" value="check5" id="ch5">
  <label for="ch2">check5</label>
</form>

<tt id="results"></tt>



Aucun commentaire:

Enregistrer un commentaire