Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Trouble finding hidden table

Reply
Thread Tools

Trouble finding hidden table

 
 
avanti
Guest
Posts: n/a
 
      12-30-2006
Hi,

I have some JavaScript code in an ASP page that shows or hides a table
whenever a radio button is checked or unchecked. I use the
table.style.dispay property to do this.

However, in some cases the table is hidden on page_load. So, JS cannot
find the table by ID and gives error whenever the radio button is
clicked. Is there a way to solve this in JS?

Thanks,
Avanti

 
Reply With Quote
 
 
 
 
Daz
Guest
Posts: n/a
 
      12-30-2006

avanti wrote:

> Hi,
>
> I have some JavaScript code in an ASP page that shows or hides a table
> whenever a radio button is checked or unchecked. I use the
> table.style.dispay property to do this.
>
> However, in some cases the table is hidden on page_load. So, JS cannot
> find the table by ID and gives error whenever the radio button is
> clicked. Is there a way to solve this in JS?
>
> Thanks,
> Avanti


I'm not entirely sure why the problem seems to be intermitent. I would
suggest you find out why the table is being hidden to start with.

What is the error you are getting?

Setting the display attribute to 'none' only hides the table from view,
not from the DOM.

Here's some code that might help. Note that the table starts out
hidden, and a reference to the table is only obtained when the 'Toggle'
span is clicked upon.

<html>
<head>
<script type="text/javascript" language="javascript">
function toggleTable()
{
var table = document.getElementById('table');
table.style.display = (table.style.display) ? '' :
'none';
}
</script>
</head>
<body>
<span onclick="toggleTable()">Toggle</span>
<table style='display: none;' id="table">
<tr>
<td>
Top Left
<td>
Top Right
<tr>
<td>
Bottom Left
<td>
Bottom Right
</table>
</body>
</html>

If you are still having problems, please post some of your code.

Best regards.

Daz.

 
Reply With Quote
 
 
 
 
avanti
Guest
Posts: n/a
 
      01-02-2007
Thanks this helped with some other changes.

Daz wrote:
> avanti wrote:
>
> > Hi,
> >
> > I have some JavaScript code in an ASP page that shows or hides a table
> > whenever a radio button is checked or unchecked. I use the
> > table.style.dispay property to do this.
> >
> > However, in some cases the table is hidden on page_load. So, JS cannot
> > find the table by ID and gives error whenever the radio button is
> > clicked. Is there a way to solve this in JS?
> >
> > Thanks,
> > Avanti

>
> I'm not entirely sure why the problem seems to be intermitent. I would
> suggest you find out why the table is being hidden to start with.
>
> What is the error you are getting?
>
> Setting the display attribute to 'none' only hides the table from view,
> not from the DOM.
>
> Here's some code that might help. Note that the table starts out
> hidden, and a reference to the table is only obtained when the 'Toggle'
> span is clicked upon.
>
> <html>
> <head>
> <script type="text/javascript" language="javascript">
> function toggleTable()
> {
> var table = document.getElementById('table');
> table.style.display = (table.style.display) ? '' :
> 'none';
> }
> </script>
> </head>
> <body>
> <span onclick="toggleTable()">Toggle</span>
> <table style='display: none;' id="table">
> <tr>
> <td>
> Top Left
> <td>
> Top Right
> <tr>
> <td>
> Bottom Left
> <td>
> Bottom Right
> </table>
> </body>
> </html>
>
> If you are still having problems, please post some of your code.
>
> Best regards.
>
> Daz.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate Hidden field on post back and retrieve value from Hidden Field Rick ASP .Net 3 04-13-2010 05:38 PM
Win 7 folders hidden despite 'show hidden' checked Boppy NZ Computing 10 01-23-2010 02:56 AM
How would I discover the text in a block element hidden by overflow:hidden style being set? SolarCanine Javascript 2 09-20-2005 06:27 PM
Re: Finding "hidden" syntax errors eltronic@juno.com Python 1 06-14-2004 12:05 AM
Finding "hidden" syntax errors Larry Bates Python 1 06-13-2004 08:50 AM



Advertisments