SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Checking all items in a check box form

    Is there way to make it to where if someone clicks one check box the rest get checked without knowing the names of the other form names? Meaning if I load a form with a dynamic number of entries, maybe it will show 8 check boxes or perhaps 6 and I wont know the name of the form fields. So is there a way if they click one main check box the rest get checked?

    Thanks
    Silly

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
     with(document.frmChkBoxes)
       {
    	 if(elements[0].checked)
    	 { 
    		for (i = 1; i < elements.length; i++)
    		{
    		  if (elements[i].type == 'checkbox')
    			 elements[i].checked = true;
    		}
    	 }
    


    if you want an explanation, see the 'Check them All" script/tutorial at my site (GrassBlade)

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


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
  •