?
Solved

Show Hide in TR in a ASP loop

Posted on 2008-11-14
6
Medium Priority
?
211 Views
Last Modified: 2013-12-25
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
Comment
Question by:wellsuited
  • 4
  • 2
6 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22965419
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
 
LVL 1

Author Comment

by:wellsuited
ID: 22965440
no I am pulling the data from a database. And I want to be able to toggle the details.
0
 
LVL 82

Expert Comment

by:hielo
ID: 22965449
>>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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:wellsuited
ID: 22965459
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
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 22965529
>>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
 
LVL 82

Expert Comment

by:hielo
ID: 22971088
glad to help
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question