2 Replies - 2944 Views - Last Post: 08 April 2003 - 06:35 AM

#1 Fygar  Icon User is offline

  • I liek milk!!1
  • member icon

Reputation: 6
  • View blog
  • Posts: 4,361
  • Joined: 28-March 02

Getelementid Array!?

Posted 07 April 2003 - 08:48 AM

hmm, I'm trying to figure out getElementByID stuff...

I am trying to expand and collapse rows of information and stuff by clicking a button. Well, I am able to expand and collapse one column with getElementById, but no more. I think I need an array or soemthing to do it... take a look at the code quick:

JS
  else if(ie5 || ns6){
  	var x=document.getElementsByName(id);
  	for (i=1; i<x; i++){
    if (document.getElementById(id).style.display == "none"){
    	document.getElementById(id).style.display = "block";
    }else{
    	document.getElementById(id).style.display = "none";
    }
  	}
  }



HTML
<style>
.branch{
	display: none;
	border-bottom: '1px solid black'
}
</style>
<table>
	<tr>
  <td>
  	<input type="button" value="Show" class="niceButton" onclick="show('Branch0')" />
  </td>
  <td>
  	<input type="button" value="Hide" class="niceButton" onclick="hide('Branch0')" />
  </td>
  <td>
  	test
  </td>
	</tr>
	<tr>
  <td id="branch0" class="branch">
  	Column1.1
  </td>
  <td id="branch0" class="branch">
  	Column1.2
  </td>
  <td id="branch0" class="branch">
  	Column1.3
  </td>
	</tr>
	<tr>
  <td id="branch0" class="branch">
  	Column2.1
  </td>
  <td id="branch0" class="branch">
  	Column2.2
  </td>
  <td id="branch0" class="branch">
  	Column2.3
  </td>
	</tr>
</table>



So you see I am wanting to loop through getElementById, but I have no method of progressing through, it just stays on the first record. So I am wondering if there is a way to loop through every ID set at "branch0" or whatever other name it is set at. Or maybe there is just a better way of doing this. It needs to expand multiple columns too. So that is why I don't jsut hide the <tr> tag. Thanks!


EDIT: BTW, this is going to be used for drilling down on details in a table deal...

This post has been edited by Fygar: 07 April 2003 - 08:51 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Getelementid Array!?

#2 Koenie  Icon User is offline

  • What?!

Reputation: 0
  • View blog
  • Posts: 1,313
  • Joined: 08-July 02

Re: Getelementid Array!?

Posted 08 April 2003 - 06:13 AM

can you show me the function show() ?????
Was This Post Helpful? 0
  • +
  • -

#3 Fygar  Icon User is offline

  • I liek milk!!1
  • member icon

Reputation: 6
  • View blog
  • Posts: 4,361
  • Joined: 28-March 02

Re: Getelementid Array!?

Posted 08 April 2003 - 06:35 AM

NO

Hah... jk. That top JS part was a chunk of show() I should have said. But it's all good. My Google powers have prevailed once more! I found something similar that is more effective. Thanks though.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1