how to select/deselect all checkboxes in grid?
-
hi all, I have a grid which contains checkboxes(similar to mail inbox).I have one href control outside the grid.When i click all the chekboxes inside the grid must b selected.When i click again they should b deselected.Can any1 tell me how to accomplish this using client side code?(i mean in javascript) i wrote a code like this var isChecked = false; function check() { isChecked = !isChecked; var checkboxes = document.getElementsByTagName("INPUT"); var index; for(index = 0; index < checkboxes.length; index++) { if(isChecked) checkboxes[index].checked = true; else checkboxes[index].checked = false; } } Check/Uncheck All The above code is working 5n if the page has no other select controls(radiobutton,checkbox,listbox)outside the grid. But i have one radiobutton control in my page.So when i click the href all the checkboxes inside the grid gets checked but the radiobutton also gets checked.That shoud not happen.How 2 accomplish this?
T.Balaji
-
hi all, I have a grid which contains checkboxes(similar to mail inbox).I have one href control outside the grid.When i click all the chekboxes inside the grid must b selected.When i click again they should b deselected.Can any1 tell me how to accomplish this using client side code?(i mean in javascript) i wrote a code like this var isChecked = false; function check() { isChecked = !isChecked; var checkboxes = document.getElementsByTagName("INPUT"); var index; for(index = 0; index < checkboxes.length; index++) { if(isChecked) checkboxes[index].checked = true; else checkboxes[index].checked = false; } } Check/Uncheck All The above code is working 5n if the page has no other select controls(radiobutton,checkbox,listbox)outside the grid. But i have one radiobutton control in my page.So when i click the href all the checkboxes inside the grid gets checked but the radiobutton also gets checked.That shoud not happen.How 2 accomplish this?
T.Balaji
Check It Selecting/DeSelecting CheckBox inside Gridview by Samir in Codeproject[^]
cheers, Abhijit
-
hi all, I have a grid which contains checkboxes(similar to mail inbox).I have one href control outside the grid.When i click all the chekboxes inside the grid must b selected.When i click again they should b deselected.Can any1 tell me how to accomplish this using client side code?(i mean in javascript) i wrote a code like this var isChecked = false; function check() { isChecked = !isChecked; var checkboxes = document.getElementsByTagName("INPUT"); var index; for(index = 0; index < checkboxes.length; index++) { if(isChecked) checkboxes[index].checked = true; else checkboxes[index].checked = false; } } Check/Uncheck All The above code is working 5n if the page has no other select controls(radiobutton,checkbox,listbox)outside the grid. But i have one radiobutton control in my page.So when i click the href all the checkboxes inside the grid gets checked but the radiobutton also gets checked.That shoud not happen.How 2 accomplish this?
T.Balaji
hi abijit, thats fantastic.but my requirment is when the href is clicked this should occur and moreover href is NOT inside the grid.kindly go thru my code.Is it possible to make any check that checkboxes are inside the grid and continue ,like var isChecked = false; function check() { isChecked = !isChecked; var checkboxes = document.getElementsByTagName("INPUT"); //HERE I WANT TO CHECK CONDITION LIKE if(document.getElementbyid("ct100_gvclust1")=="ct100_gvclust1") // AND CONTINUE var index; for(index = 0; index <checkboxes.length;>{ if(isChecked) checkboxes[index].checked = true; else checkboxes[index].checked = false; } }
T.Balaji
-
Check It Selecting/DeSelecting CheckBox inside Gridview by Samir in Codeproject[^]
cheers, Abhijit
-
hi all, I have a grid which contains checkboxes(similar to mail inbox).I have one href control outside the grid.When i click all the chekboxes inside the grid must b selected.When i click again they should b deselected.Can any1 tell me how to accomplish this using client side code?(i mean in javascript) i wrote a code like this var isChecked = false; function check() { isChecked = !isChecked; var checkboxes = document.getElementsByTagName("INPUT"); var index; for(index = 0; index < checkboxes.length; index++) { if(isChecked) checkboxes[index].checked = true; else checkboxes[index].checked = false; } } Check/Uncheck All The above code is working 5n if the page has no other select controls(radiobutton,checkbox,listbox)outside the grid. But i have one radiobutton control in my page.So when i click the href all the checkboxes inside the grid gets checked but the radiobutton also gets checked.That shoud not happen.How 2 accomplish this?
T.Balaji
Your tag <a onclick="return check_uncheck1(this );" id="Check" runat="server" href="#">check</a> and Javascript function is as like this function check_uncheck1(Val) { var ValChecked = Val.checked; var ValId = Val.id; var frm = document.forms[0]; // Loop through all elements for (i = 0; i < frm.length; i++) { if(frm.elements[i].checked == true) { frm.elements[i].checked=false; } else { frm.elements[i].checked=true; } } }
-
Good !!!
cheers, Abhijit