How to hide table rows and show them when user click a different row?

  • Thread starter Thread starter RA
  • Start date Start date
R

RA

Hi

I want to have a FAQ so that when the user clicks the question the answer
will be shown below the questions. How do I do it? I use c# with asp.net.

Thanks
 
Hi,
that's probably a client side thing. Something like
<script type="text/javascript">
function showFaq(id){
if(!document.getElementById){return;}
else{
s=document.getElementById('answer'+id);
s.style.display='block';}}

function hideAllFaqs(){
if(document.getElementById && !window.opera){
document.write('<style>#questions div{display:none;}</style>')}
}
</script>
<body onload="hideAllFaqs();">
<div id="questions">
<p><a onclick="showFaq('1'); return false;" href="javascript:;">Why Is
That?</a></p>
<div id="answer1">Just Because</div>
<p><a onclick="showFaq('2'); return false;"
href="javascript:;">When?</a></p>
<div id="answer2">Sometime</div>
etc

Jon
 
Back
Top