Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 06-10-2009, 09:52 AM Show Hide row?
Experienced Talker

Posts: 43
Trades: 0
Hi everybody

I've found this javascript code to show and hide a table row..

http://www.javascriptf1.com/tutorial...ow.html?page=3

I would like to change it so when you enter the site, the row is hidden, and then when you click it it appears. At the moment it is the other way around. How to change this?


Code:
<script type="text/javascript">
function displayRow(){
var row = document.getElementById("captionRow");
if (row.style.display == '')  row.style.display = 'none';
else row.style.display = '';
</script>
I though that i just should change the placement of none like belowe. But that didnt work. WHat should i do?

Code:
<script type="text/javascript">
function displayRow(){
var row = document.getElementById("captionRow");
if (row.style.display == 'none')  row.style.display = '';
else row.style.display = 'none';
</script>
Sgbirkelund is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-10-2009, 06:23 PM Re: Show Hide row?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Don't change the script, just set a CSS attribute of "display: none" on the TR in the static HTML.
HTML Code:
<tr id="captionRow" style="display: none">
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.

Last edited by wayfarer07; 06-10-2009 at 06:24 PM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 06-11-2009, 09:52 AM Re: Show Hide row?
Extreme Talker

Posts: 246
Trades: 0
looks like the function isn't properly formatted with braces.

function displayRow()
{
var row = document.getElementById("captionRow");

if (row.style.display == 'none')
{
row.style.display = '';
}
else
{
row.style.display = 'none';
}
}



When trying to debug javascript sometimes using alert statements can help to verify the information you are working with.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
stbuchok is offline
Reply With Quote
View Public Profile
 
Old 06-11-2009, 06:08 PM Re: Show Hide row?
Experienced Talker

Posts: 43
Trades: 0
thx wayfarer07. It worked..
Sgbirkelund is offline
Reply With Quote
View Public Profile
 
Old 06-11-2009, 07:50 PM Re: Show Hide row?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
You're welcome
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 06-13-2009, 01:16 PM Re: Show Hide row?
Experienced Talker

Posts: 43
Trades: 0
What if i want multiplie text fields on a page, with this function. Do you then have to copy the script as many time as there are text fields or is there a smart way to do it.

It is for a FAQ page where you can see the questions and then when you click it, you see the answer.
Sgbirkelund is offline
Reply With Quote
View Public Profile
 
Old 06-15-2009, 03:15 PM Re: Show Hide row?
Experienced Talker

Posts: 43
Trades: 0
anybody?
Sgbirkelund is offline
Reply With Quote
View Public Profile
 
Old 06-16-2009, 06:33 AM Re: Show Hide row?
Junior Talker

Posts: 3
Name: Licurici Alexandru
Trades: 0
<script type='text/css'>.hideme{display: none;}</script>
<tr id="captionRow" class='hideme'>
hip_hop_x is offline
Reply With Quote
View Public Profile
 
Old 06-16-2009, 08:24 AM Re: Show Hide row?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Quote:
<script type='text/css'>
There's no such thing as a script with a type of text/css.
Quote:
Originally Posted by Sgbirkelund View Post
What if i want multiplie text fields on a page, with this function. Do you then have to copy the script as many time as there are text fields or is there a smart way to do it.

It is for a FAQ page where you can see the questions and then when you click it, you see the answer.
You should probably use a loop, and attach an event to each textarea, with getElementsByTagName("textarea"), for example. Then, you could have a class on the textarea with the same name of the ID it needs to access...
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.

Last edited by wayfarer07; 06-16-2009 at 08:26 AM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Show Hide row?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.50376 seconds with 12 queries