Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Location
    United States
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry CheckAll giving me null value

    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

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,634
    Thanks
    0
    Thanked 649 Times in 639 Posts
    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).
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New to the CF scene
    Join Date
    Oct 2011
    Location
    United States
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    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 ?

  • #4
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,078
    Thanks
    38
    Thanked 498 Times in 492 Posts
    Can you show the BRIEF section of the JS and HTML code that is effected by the 'MoveAll()' function?
    Or a live link?

  • #5
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Quote Originally Posted by Matt.Swaggi View Post
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •