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

LVL 1
wellsuitedAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hieloCommented:
glad to help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.