checkbox looses value on server when clicking next button of form
checkbox looses value on server when clicking next button of form
manoharsolanki123
Posts: 8Questions: 0Answers: 0
Hi,
I am very new to datatables. But I am very much impressed with the functionality of what all I have seen.
I am stuck up at one point.
PRELUDE:
I am putting checkbox at each row with the same name with different value in a loop as:
Now I am able to get the checkbox displayed and a user selects 1/more on first page and goes to next page and again selects some more entries and finally submits a page.
On submit I have used:
$('#form').submit( function() {
var sData = $('input', oTable.fnGetNodes()).serialize();
alert( "The following data would have been submitted to the server: \n\n" + sData);
if (sData.length==0){
alert("You must select at least 1 checkbox.");
return false;
}
} );
Problem:
The alert here shows pcMem=0&pcMem=1&pcMem=10&pcMem=11,
<0 & 1 are on first page and 10 & 11 are on next page>
But on the server I am getting values of only the page which was last selected. i.e. I am getting only values pcMem=10&pcMem=11 and not 0 & 1. What might be the problem and how do I achieve previously selected values?
I use the below server side code in JSP:
for(int i=0; i< request.getParameterValues("pcMem").length; i++){
str = request.getParameterValues("ename")[i];
System.out.println("SELECTED EMP "+str);
}
Kindly help.
Manohar Solanki
I am very new to datatables. But I am very much impressed with the functionality of what all I have seen.
I am stuck up at one point.
PRELUDE:
I am putting checkbox at each row with the same name with different value in a loop as:
Now I am able to get the checkbox displayed and a user selects 1/more on first page and goes to next page and again selects some more entries and finally submits a page.
On submit I have used:
$('#form').submit( function() {
var sData = $('input', oTable.fnGetNodes()).serialize();
alert( "The following data would have been submitted to the server: \n\n" + sData);
if (sData.length==0){
alert("You must select at least 1 checkbox.");
return false;
}
} );
Problem:
The alert here shows pcMem=0&pcMem=1&pcMem=10&pcMem=11,
<0 & 1 are on first page and 10 & 11 are on next page>
But on the server I am getting values of only the page which was last selected. i.e. I am getting only values pcMem=10&pcMem=11 and not 0 & 1. What might be the problem and how do I achieve previously selected values?
I use the below server side code in JSP:
for(int i=0; i< request.getParameterValues("pcMem").length; i++){
str = request.getParameterValues("ename")[i];
System.out.println("SELECTED EMP "+str);
}
Kindly help.
Manohar Solanki
This discussion has been closed.
Replies
Allan