vendredi 7 août 2015

jquery .map() checkbox

$(function() {
  $('input[type=checkbox]:checked').map(function() {
    alert($("#chk_option").val());
    $("#chk_option").val(this.value);
  }).get();
});

HTML code

<div>

  <center>
    <form id="form_tarif" class="form-horizontal" style="padding-top:57px;" action="pricesinput" method="POST">

      <input type="hidden" id="chk_option" name="chk_option">

      <input type="hidden" id="chk_option_remove" name="chk_option_remove">

      <c:forEach items="${option_tarif_list}" var="option_tarif" varStatus="loop">
        <div class="checkbox1">
          <label>
            <input type="checkbox" name="tarif_inclue[]" value="${option_tarif.id}" class="checkboxchk" id="option_tarif_chk_${option_tarif.id}">${option_tarif.libelle}
          </label>
        </div>
      </c:forEach
   </form>
 </center>

</div>

I need the id chk_option for future use. How can i make the array of selected checkbox values included in that id.

JAVA code

I need the id as shown below

Integer trimmedOptionSplit = 0;
String optionChkStr = request.getParameter("chk_option");
String[] optionSplitStrs = optionChkStr.split(",");




Aucun commentaire:

Enregistrer un commentaire