lundi 3 octobre 2016

Why checkboxes doesen't work?

I'm turning several jsp pages on dialogs using Tiles framework.

The problem is that several jsp have checkboxes and those checkboxes seems no work on dialog.

This is a sample of how my checkboxes work:
Javascript:

 <script type="text/javascript">
    function setValueCheckbox(identifier) {
        if (identifier == "typeDpr") {
            if ($('input[name=typeDpr]').is(':checked')) {
                $("#typeDpr").val("DPR");
            } else {
                $("#typeDpr").val(null);
            }
        }   
    }

</script>

<c:set var="dpr" value="DPR" />
 <c:choose>
    <c:when test="${requestScope.view.from eq insert}">
        <c:set value="${param.typeDpr}" var="varTypeDpr" />
    </c:when>
    <c:otherwise>
        <c:set value="${requestScope.view.typeDpr}" var="varTypeDpr" />
    </c:otherwise>
</c:choose>

And the checkbox:

 <td>
   <c:choose>
    <c:when test="${varTypeDpr eq dpr}">
      <input type="checkbox" id="typeDpr" name="typeDpr" value="${varTypeDpr}" onclick="javascript: setValueCheckbox(this.id);" checked="checked" />
   </c:when>
  <c:otherwise>
      <input type="checkbox" id="typeDpr" name="typeDpr" value="${varTypeDpr}" onclick="javascript: setValueCheckbox(this.id);" />
  </c:otherwise>
  </c:choose>
     <fmt:message key="investigation.events.section.typeDpr" bundle="${i}" />
</td>

So, reasuming: if not select my checkbox should be set to NULL, instead the checkbox should be valued with a String ("DRP" on this case). The problem: if i let stay the checboxes all works perefectly but if i try click on a checkbox, they are alwayys valuated as null.




Aucun commentaire:

Enregistrer un commentaire