Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding Table Data

Status
Not open for further replies.

MISdad

Technical User
May 5, 2004
34
0
0
I have an asp page that is pulling permit and inspection data. I am showing the permit data and then doing a loop below that to show the inspections for that specific permit number.

Since there can be 10 or more inspections on a single permit number, I want to be able to suppress the inspection detail data until the user wants to see it and clicks on the appropriate link. I set up the collapsable table but it expands and collapses for all the inspection records in the loop not just the one that I click on.

Any suggestions??
 
Yes - show us the code you have - it's hard to comment when we have no idea what you're working with (and the crystal ball is broken, and all psychic powers are drained, etc etc etc, you get the idea ;-))

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
If you have the technique down for successfully expanding and collapsing tables, then why not make SEPARATE expandable/collapsable tables for each permit number. Then you need only extend your code to expand the relevant permit information.

As Dan says, we could do more if we could see the code (source code... not ASP).

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
Here's the code:

Code:
<script> 
function exp(strTag ,strAttribute){ 
var elem = document.getElementsByTagName(strTag); 
var elem1 =window.event.srcElement; 
for (var i=0;i<elem1.children.length;i++){ 
elem1.children[i].innerText=="4"?elem1.children[i].innerText="5":elem1.children[i].innerText="4"; 
} 
for (var i =0;i<elem.length;i++) 
{ 
if(elem[i].getAttribute(strAttribute)=="yes") 
{ 
elem[i].style.display=='none'? elem[i].style.display='block':elem[i].style.display='none'; 
} 
} 
} 
</script>


<table width="780" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0"> 
           <tr id =tr1 bgcolor=#ffcc66 onclick="exp('tr','exp');"> 
           <td id=td1 colspan=2 align=center width="816"></td>           
           <p align="left"><font face=Webdings color=blue>4</font> Permit Info (click to show) 
           
           <%do until temppermitno<>objRS("PERMIT_NUM")%> 
           <tr bgcolor=#ffcc66 exp="yes" style="display:none;"><td width="126"><% Response.Write objRS("PERMIT_NUM") %></td>
           <% objRS.MoveNext
           if objRS.EOF then exit do
           Loop %>
</table>
 
LFI said:
source code... not ASP

You've given us the ASP, not the client-side source code.

Can you try again, this time giving the source code that the browser sees (which you can find by viewing source)? The ASP code you've given us is about as much use as a chocolate teapot, as there's only one row!

Incidentally, a lot of bad things with your code:

1. You do not close your TR tags
2. You do not support browsers other than IE (window.event is IE-only, AFAIK)
3. Your code will not validate (using custom attributes)
4. You are using font tags
5. You do not specifgy a language for your script
6. You have no indentation in your JS (not overly bad, but still poor coding practice)

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Dan said:
5. You do not specifgy a language for your script
Whilst this is correct, the language attribute has been deprecated. The only required attribute is the type attribute (which is missing). This is the correct markup:
Code:
<script type="text/javascript">...</script>
You can read a more complete description on this specific thing on my blog:

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
That's one of those cases of knowing what you mean, and expecting everyone else to know, too.

You can still specify the [!]programming[/!] language [used for the script] using the type attribute, for example:

Code:
<script type="text/javascript">
<script type="text/vbscript">
<script type="text/tcl">

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top