473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Trouble finding hidden table

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

Dec 30 '06 #1
2 1138
Daz

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.

Dec 30 '06 #2
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.
Jan 2 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Oxygenearth | last post by:
Please who could help me with this... I had my structure in Win32, with Apache, PHP, and MySQL, I had a page in which I am transfering an image to the database in MySQL using PHP. But now I am...
2
by: Alexandre Jaquet | last post by:
Hi, Under IE I could not point why I can't get the selected value from a function here the code function Lvl_P2P(url,closeIt,delay){ //ver1.0 4LevelWebs var fabricant_box; var...
4
by: Anthony Cuttitta Jr. | last post by:
I'm working on some procedures where Access queries are exported to Excel, and then later on, those same workbooks are openned, and I need to target a specific original sheet. Sometimes there will...
1
by: leavandor | last post by:
Hello all, I've come upon a problem when trying to find where some data in my .mdb file is coming from. This database was designed by someone else several years ago, and now I've been put to...
10
by: Dixie | last post by:
I need to delete some relationships in code. How do I know what the names of those relationships are?
4
by: Jake Peters | last post by:
I'd like to know how to get a users various table privilages from a sql server (insert/delete/update), so that i can set controls to behave accordingly (read only, hidden, disable "insert" button,...
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
11
by: kennthompson | last post by:
Trouble passing mysql table name in php. If I use an existing table name already defined everything works fine as the following script illustrates. <?php function fms_get_info() { $result =...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.