SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    USA
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem while changing color

    Hi,

    I am trying to Select and Clear all the checkboxes in a frame. Well, that works fine. But, now I need to Select or clear single checkbox. Upon selection, I am changing color. But when I try to select/clear single box it works strangly. If I selected a checkbox first and then click checkall, the previously selected one, does not change it's color. I have checkboxes in a row and I am changing row color.

    Here are my functions ---


    function CheckAllCheckBoxes(FormName, FieldName, CheckValue)
    {
    if(!document.forms[FormName])
    return;
    var objCheckBoxes = document.forms[FormName].elements[FieldName];
    if(!objCheckBoxes)
    return;

    var countCheckBoxes = objCheckBoxes.length;
    if(!countCheckBoxes)
    objCheckBoxes.checked = CheckValue;
    else

    // set the check value for all check boxes
    for(var i = 0; i < countCheckBoxes; i++)
    objCheckBoxes[i].checked = CheckValue;

    document.getElementById('foldertable').style.background='#d5d7de';
    document.getElementById('datatable').style.background='#d5d7de';
    }

    function ClearAllCheckBoxes(FormName, FieldName, CheckValue)
    {
    if(!document.forms[FormName])
    return;
    var objCheckBoxes = document.forms[FormName].elements[FieldName];
    if(!objCheckBoxes)
    return;
    var countCheckBoxes = objCheckBoxes.length;
    if(!countCheckBoxes)
    objCheckBoxes.checked = CheckValue;
    else

    // set the check value for all check boxes

    for(var i = 0; i < countCheckBoxes; i++)
    objCheckBoxes[i].checked = CheckValue;

    document.getElementById('foldertable').style.background='#e5e6e9';
    document.getElementById('datatable').style.background='#e5e6e9';
    }

    function SingleBox(tid,cid)
    {
    if(document.getElementById(cid).checked){ document.getElementById(tid).style.background='#d5d7de';} else
    { document.getElementById(tid).style.background='#e5e6e9';}

    }

    What is worng? Any idea? It's kind of urgent for me.
    Thanks,

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I selected a checkbox first and then click checkall, the previously selected one, does not change it's color.
    See comments:

    Code:
    if(!countCheckBoxes)//then one checkbox with that name
    objCheckBoxes.checked = CheckValue;
    //no row color change
    
    else  //then multiple checkboxes with that name
    
    // set the check value for all check boxes
    for(var i = 0; i < countCheckBoxes; i++)
    objCheckBoxes[i].checked = CheckValue;
    
    //color change
    document.getElementById('foldertable').style.background='#d5d7de';
    document.getElementById('datatable').style.background='#d5d7de';
    }
    In the future use code tags when posting code.

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    USA
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry,I will rememeber hereon


Bookmarks

Posting Permissions

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