samedi 1 octobre 2016

How to get Selected CheckBox value in ajax and pass to action class in struts2

    <tbody>
                    <s:iterator value="pageList" var="quesvar" status="questat">
                    <s:hidden value="%{pageList[#questat.index].pageID}" name="pageDTO.pageID" id="pageID"></s:hidden>
                    <s:hidden value="%{pageList[#questat.index].roleID}" name="pageDTO.roleID" id="roleID"></s:hidden>
                        <tr class="item">
                        <td valign="top" class="style11" style="width: 20%;"><s:checkbox name="pageDTO.rolePageMapID" id="isSelect" value="%{pageList[#questat.index].rolePageMapID}" styleClass="isSelected"   theme="simple"/></td>
                            <td valign="top" class="style11" style="width: 20%;"><s:property  value="pageList[#questat.index].pageCode"/><%--  <s:textfield class="name" id="valueParam" name="globalParamDTO.paramValue" value="paramList[#questat.index].paramValue" theme="simple" readOnly="true" ></s:textfield> --%> <%-- <s:property value="%{#rep.paramValue}"/> --%></td>
                            <td valign="top" class="style11" style="width: 20%;"><s:property  value="pageList[#questat.index].pageName"/> </td>
                            <td valign="top" class="style11" style="width: 20%;"><s:checkbox name="pageDTO.allRights" value="%{pageList[#questat.index].allRights}" styleClass="isSelected" fieldValue="1"  theme="simple"/></td>
                    </tr>
                    </s:iterator>
                <tr>
    <tr>
                    <td valign="top" colspan="" class="style10"><input type="button" name="SaveRolePageMapBtn" id="SaveRolePageMapBtn" value="Save"  onClick= "saveRolePageMap(this.isSelect)" title="Save" /> </td>
                    </tr>


    function saveRolePageMap(isSelect)
     {
 var data = new Array();
         $("input[name='pageDTO.rolePageMapID']:checked").each(function(i) {
            data.push($(this).val());
            alert(data.push($(this).val()));
         });
   $("#ajax_loader").show();

        $.ajax({
            url : "editPageDetail",
            type : "POST",
            enctype: 'multipart/form-data',
            data : 'pageDTO.pageID='+pageID,
            async : true,
            cache : false,

             complete: function(){
                    $("#ajax_loader").hide();
                },
            success : function (data) {
                $("#popEditPageDiv").html(data);

            }
            });
        }

How can I pass selected multiple selected checkbox value in ajax . by using above code I am getting only 2,4,6,8,10 values but it is not actual ID of the page . How can I get values of selected checkBox values ? h




Aucun commentaire:

Enregistrer un commentaire