Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cant Retain value of check box from one page to another page on pagination  RSS feed

Ranch Hand
Posts: 300
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Again.
I am in scenario where i m stuck.i cant go ahead.
I can retain selected value of check box on the child page.but
when i close window with window.close and i got all values with the id.
but when i again open child page and close it comes with the old value and both value(old and new value)value.So i want the id on the parent page without duplicacy .doesnt matter how many times i open the child page .
here it increment every time.

child Page is not submitted i use href for pagination.So pagination is also there.
I post the code mostly java Script.

Is there any other way through session that i can get the id on the parent page and also hold the id of selected check box through navigation on child page.

child page=new jsp open from the window
parent page = jsp from which i open the child

I open a child page with as mentioned Below.
I also pass some hidden variable.

on click = "

input type="text" name="parent" id="parent" value=""
input type="hidden" name="allProductTotalRow" id="allProductTotalRow" value="0"
input type="hidden" name="allCheckValue" id="allCheckValue" value="0"

I open window with the help of javascript once i selected all item need
to close window and get the list of id back to the parent page.

How to use session for this, i used java script.

Code for Child page:-
check box is generated dynamically from database.

input type="checkbox" name="checkitem_=rs.getRow()"
id="checkitem_"=rs.getRow()" value="=rs.getString("itemid")
on click="checkValue(this);"

on click of check box i call function to add id of all check boxes.

Function checkValue():
var parent = window.opener.document.getElementById("parent")
parent.value = parent.value + "," + currObj.value;

I also check for duplicacy with javascript.

3)On click of Add item button window will close and value will display on the parent page with inner html.I use pagination with href on child where
i pass query string to retrive dnt have chance to submit Page.

Add Item:
var count=0;
var check = temp.value.split(',');
var count=0;
var itemname="";
var itemrlcode="";
var itemunit="";
var tempid = document.getElementById("parent");

for(var i=1;i &lb check.length;i++)

alert("Please Select To Add");
return false;
var check = temp.value.split(',');
var id = tempid.value.split(',');
var totalNoOfRows = window.opener.document.getElementById
for(var i=1;i&lbcheck.length;i++)
var row = window.opener.document.getElementById
("allProductTable").insertRow(); = "itemRow_"+parseInt(totalNoOfRows);
var newItemName = row.insertCell();
var newItemrl = row.insertCell();
var newItemunit = row.insertCell();
var newItemInsertText = row.insertCell();
newItemName.innerHTML = check[i];
newItemrl.innerHTML = code[i];
newItemunit.innerHTML = unit[i];
concatAllValues = id[i]+","+check[i]+",'"+code[i]
newItemInsertText.innerHTML = "input type='hidden'
value=\""+ concatAllValues +"\"&lb";

totalNoOfRows = totalNoOfRows + 1;
newItemInsertText.innerHTML = "input type='hidden'
name='allItemValues_"+ (parseInt(totalNoOfRows)+1)+"' value=\""+
concatAllValues +"\"";"none";
window.opener.document.getElementById("allProductTotalRow").value = parseInt(window.opener.document.getElementById("allProductTotalRow").value) + 1;
window.close() ;

I tired this way it doesnt working every time i close window it display
with old+new+old value.
May because of javascript parent variable. ?

How can i use SESSION for retaining value of check box ?
I have pagination on child page, i am not submitting the page.
i use href and passing query string for Pagination.

when i close window i need id of checked row on parent page.

Need to find solution ,can any body help me come out from this?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!