Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetElementbyName Checkboxes in table

Status
Not open for further replies.

MrTrue

Technical User
Jul 28, 2008
46
US
I'm trying to loop through all checkboxes in an HTML table that is built dynamically (size will vary). I think I understand the basic premise and I beleive I need to call out the parent element (the table) to search for only checkboxes in that table. I think I'm close but I need some help. Thanks in advance!

Code:
function check_all

    dim orow
    dim CBox

    set orow=document.getElementsByName("Approve_Table") (0).getElementsbyname("input")
    Cbox = orow.count
    
    for i = 0 to Cbox 
	orow(i).checked = "Yes"
    next

end function
 
[tt] dim cinput,oinput
set cinput=document.getElementsByName("Approve_Table")(0).getElementsby[red]Tag[/red]name("input")
for each oinput in cinput
if strcomp(oinput.type,"checkbox",1)=0 then
oinput.checked=true
end if
next[/tt]

ps: what would it be the idea to give a table a name rather than an id? and then use getElementById()?
 
Thanks so much for your help! As far as the getElementById vs. getElementbyName, I wasn't 100% sure what would be best I have limited exposure to the getelementsby. Since the table is built dynamically I can just switch my code to give the table an ID, then I'll follow your recommendation. Thanks again tsuji!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top