need help with radiolist and checkboxlist in javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsaray101
    New Member
    • Aug 2007
    • 31

    need help with radiolist and checkboxlist in javascript

    I have an asp.net page that has one radiolist (called lstcheck) and one checkboxlist (call lstExchange). Depending on the which radiolist item is checked, I need to clear the checkbox list or check them all. I have this function so far but it is not working:

    Code:
    function checkAll()
    {
         var radiolist=document.getElementById("lstCheck");
         var checklist=document.getElementById("lstExchange");
    
    
            if (radiolist[3].checked=true)
              {
                  for (var j=0; j<checklist.lenght; j++)
                    {
                       checklist[j].checked=true;
                    }
               }
    
    }
    I add this line to pageload event on the vb side:

    lstCheck.Attrib utes.Add("OnCli ck", "checkAll() ;")
  • scripto
    New Member
    • Oct 2006
    • 143

    #2
    try this

    if (radiolist[3].checked==true)
    {
    for (var j=0; j<checklist.len ght; j++)
    {
    checklist[j].checked=true;

    Comment

    • gsaray101
      New Member
      • Aug 2007
      • 31

      #3
      I keep getting:

      "Object doesn't support this property or method" error

      Comment

      • gsaray101
        New Member
        • Aug 2007
        • 31

        #4
        this should be straight forward but it does not seem to be working:

        [code=javascript]function function_checka ll()
        {

        var chk=document.ge tElementById("f orm1");
        var chk1=chk.lstExc hange;
        var chk2=chk.btnRad io100;
        if (chk2.checked ==true ){

        for (i=0; i<26; i++)
        {
        chk1[i].checked=true;
        }
        }

        }[/code]
        Last edited by acoder; Feb 12 '08, 08:26 AM. Reason: Added code tags

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          length is spelt incorrectly. Also use document.getEle mentsByName("ls tCheck") to get the radio button list.

          Comment

          Working...