UncheckAll not updated Form?

When I am check multiple checkboxes form jQuery dialog box form updated i used the below code

$(".chk").prop('checked', true); 

and the same code when i click UncheckAll not removed checked attribute i used the below code

$('.chk:checkbox').prop('checked', false); 

then i changed to

$(".chk").val(0);
$(".chk").removeAttr("checked"); 
console.log(this); 

Here remove all checked attribute but when i submit the form that form not updated the same thing click CheckAll working fine but UncheckAll not working what is problem

<input type="checkbox" class="chk" id="meters" name="iDs" value="0" ></input>
<input type="checkbox" class="chk" id="meters" name="iDs" value="0" ></input>

In my jps page multiple elements are there with name ids

In From class property like

Integer[] iDs;

This form maintain in session When click UncheckAll Button remove all Checked attributes and values is set to 0 the code is above when submit form using @ModelAttribute from property iDs like [2,3,5] previous values maintain i am expecting [0] array

When Click CheckAll updated form the result array in my Form calss is like iDs = [1,2,3,4,5]

When UncheckAll not working what is problem

I am using jquery 1.9.1 api

finally i tryed this but in from class having a property like Integer[] iDs so not bind


You need to update your input 's name to Ids[] :

<input type="checkbox" class="chk" id="meters" name="Ids[]" value="0" ></input>

That way it will be sent as array.


Keep in mind, that when you uncheck a checkbox, its value is not sent in http-request. So I guess your client-side code works just fine. And you have to give a thorough look at your server-side code. Perhaps, this answer could be of some help to you.

链接地址: http://www.djcxy.com/p/71036.html

上一篇: asp.net jquery checkall /取消选中所有复选框

下一篇: 取消选中所有未更新的表单?