• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Show Hide in TR in a ASP loop

How do I modify this to work in a loop?
<script language="javascript" type="text/javascript">
   function FuncShowHide(){
      
      if (document.getElementById('hideShow').style.display == document.getElementById('trX').style.display){
         document.getElementById('hideShow').style.display = "none";
      } else {
         document.getElementById('hideShow').style.display = document.getElementById('trX').style.display
      }
   }
</script>
 
<table border="1">
   <tr id="trX" onClick="FuncShowHide()">
      <td>text</td>
   </tr>
   <tr id="hideShow" style="display:none">
      <td>Hide / Show this Row</td>
   </tr>
</table>

Open in new window

0
wellsuited
Asked:
wellsuited
  • 4
  • 2
1 Solution
 
hieloCommented:
what do you mean by "work in a loop"? It is already alternating between show and hide whenever you click on it. Are you trying to provide a "blinking" effect?
0
 
wellsuitedAuthor Commented:
no I am pulling the data from a database. And I want to be able to toggle the details.
0
 
hieloCommented:
>>And I want to be able to toggle the details.
OK, so on what you posted your details will go where you have "Hide / Show this Row", which is already working. What's the problem?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
wellsuitedAuthor Commented:
When I repeat the table rows they all have the same ID, I think I need to numbers them so that they are all different.
0
 
hieloCommented:
>>I think I need to numbers them so that they are all different.
Yes. ALL ids on a webpage MUST be unique throughout the page. Try:
<script language="javascript" type="text/javascript">
function FuncShowHide( eId ){
	var e=document.getElementById(eId);
	if( e )
		e.style.display = (e.style.display=="none"?"":"none");
return e;
}
</script>
 
<table border="1">
   <tr id="handle_1" onClick="FuncShowHide( this.id.replace('handle','detail') )">
      <td>text</td>
   </tr>
   <tr id="detail_1" style="display:none">
      <td>Hide / Show this Row</td>
   </tr>
 
   <tr id="handle_2" onClick="FuncShowHide(  this.id.replace('handle','detail')  )">
      <td>text</td>
   </tr>
   <tr id="detail_2" style="display:none">
      <td>Hide / Show this Row</td>
   </tr>
 
   <tr id="handle_3" onClick="FuncShowHide(  this.id.replace('handle','detail')  )">
      <td>text</td>
   </tr>
   <tr id="detail_3" style="display:none">
      <td>Hide / Show this Row</td>
   </tr>
 
</table>

Open in new window

0
 
hieloCommented:
glad to help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now