...

View Full Version : CheckAll giving me null value



Matt.Swaggi
03-07-2012, 09:28 PM
When i did a view source , checkbox names are displayed as MedicalAction_listOfTransfers_[0]__rowSelected'
so each checkbox has different name and id as well

all i am trying to do here is to put a checkall/uncheckall option , also in the jsp page we have a pagination
so is that something that cause the checkbox value as null ?



function MoveAll(){


var lengthofRecords = document.getElementById('resultsSize').value;
for (i = 0; i < lengthofRecords; i++){
var name = 'MedicalAction_listOfTransfers_'+i+'__rowSelected';
var checkBox = document.getElementById(name);
alert("check box B4: " + checkBox); - // I AM GETTING NULL VALUE HERE
checkBox.checked=checkBox.checked == false ? true:false;
alert("check box A4: " + checkBox.checked);
//checkBox.checked = checkBox.checked? true:false;
}

}

Please help i am newbie :mad:

felgall
03-07-2012, 09:49 PM
Is it the name or the id that has that value. You say it is the name and then you try to access it as the id (but with the [] dropped - which woldn't be valid in an id anyway).

Matt.Swaggi
03-07-2012, 10:27 PM
Is it the name or the id that has that value. You say it is the name and then you try to access it as the id (but with the [] dropped - which woldn't be valid in an id anyway).

It is the Id and the input type is checkbox .

so it works when the record is displayed in one single page , but the code is not working when it has pagination that mean when it has muli record across all the pages like 123. so my question is that matter i mean the pagination ?

jmrker
03-07-2012, 10:40 PM
Can you show the BRIEF section of the JS and HTML code that is effected by the 'MoveAll()' function?
Or a live link?

webdev1958
03-07-2012, 11:25 PM
so my question is that matter i mean the pagination ?

It depends on how you are doing the pagination. If it is by retrieving just the rows for each page from the database, which is how it's normally done, then unless the selections for a page are stored somewhere when a new page is selected, they will be lost.

Probably the best way to store the selections on a page is to use a session array. Other options include cookies, but they have obvious disadvantages.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum