OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

javascript visibility toggle, always starts "visible" instead of "hidden"

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> General Web Development >> javascript visibility toggle, always starts "visible" instead of "hidden"
Page: [1]
 
phillipu

 

Posts: 86
Joined: 12/12/2001
From: Seattle WA USA
Status: offline

 
javascript visibility toggle, always starts "visib... - 5/10/2004 15:21:06   
Hi all, I am using some javascript to toggle the visibility of a table, the toggle is working fine, my prob is that whenever the page with the toggle loads, it loads my table as "visible", i need the page to load with the table to toggle as "hidden", then the user can click the text link and the table becomes "visible".

Here is the javascript code -

<script language="JavaScript">
function toggle(target, iNo)
{
	obj=document.getElementById(target+String(iNo));
	obj.style.display=( (obj.style.display=='none') ? '' : 'none');
}
</script>


this code is the onclick for the toggle -

<td bgcolor="#F4F4F4" width="540" class="data" onClick="toggle('status',1)" id="rfcpe_status" style="cursor:hand">


this code is the table that is toggled -

<table width="700" border="0" cellspacing="2" cellpadding="2" bgcolor="#FFFFFF"  id="status1">


Thanks,

Phillip
Giomanach

 

Posts: 6187
Joined: 11/19/2003
From: England
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/11/2004 8:12:32   
You will need to use CSS rather than JavaScript for this. It's much easier:)

The coding would be :

<head>
<style type="text/css">
#invis{
visibilty: hidden;
}
</style>

Then you would need:

<div id="invis">
<table>
.......The Invisble Table.......
</table>
</div>

HTH

Dan

_____________________________




(in reply to phillipu)
C4RASHy

 

Posts: 5
Joined: 5/7/2009
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/7/2009 0:24:08   
So, how do i add a button that turns the text (thats inside the div class) visible?

(in reply to Giomanach)
TexasWebDevelopers

 

Posts: 722
Joined: 2/22/2002
From: Dallas, TX
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/7/2009 10:44:05   
You do it with javascript or ASP.
Here is one javascript solution:

<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}
//-->
</script>
<a onMouseOver="this.className='over'" onMouseOut="this.className='out'" onclick="toggle_visibility('div1');" style="cursor:pointer;" >show/hide div 1</a><br /><br />
<a onMouseOver="this.className='over'" onMouseOut="this.className='out'" onclick="toggle_visibility('div2');" style="cursor:pointer;" >show/hide div 2</a><br /><br />

<div id="div1" style="display:none;">
this is div 1 and stuff goes here
</div>
<div id="div2" style="display:none;">
this is div 2 - other stuff goes here
</div>

_____________________________

:)

Follow us on TWITTER

(in reply to C4RASHy)
Tailslide

 

Posts: 6692
Joined: 5/10/2005
From: Out here on the raggedy edge
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/8/2009 2:31:24   
Make sure that with JS off whatever it is is visible though otherwise you've got accessibility issues.

Have a look here for another solution: http://bonrouge.com/br.php?page=togglit

_____________________________

Little Blue Plane Web Design | Land Rover project

:)

(in reply to TexasWebDevelopers)
C4RASHy

 

Posts: 5
Joined: 5/7/2009
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/9/2009 3:01:37   
thank You a big lot! That code helped me a lot. Im using it in the menu of my site. Can You please tell me how i get more Divs to appear when I click the link? I tried with

onclick="toggle_visibility('div1');" onclick="toggle_visibility('div2');"
and
onclick="toggle_visibility('div1'); ('div2')"
and
onclick="toggle_visibility('div1', 'div2');"

but those didnt work. Help me please!

(in reply to TexasWebDevelopers)
TexasWebDevelopers

 

Posts: 722
Joined: 2/22/2002
From: Dallas, TX
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/9/2009 14:41:39   
Put your multiple divs inside the clickable div would be one way to do it.

_____________________________

:)

Follow us on TWITTER

(in reply to C4RASHy)
C4RASHy

 

Posts: 5
Joined: 5/7/2009
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/10/2009 7:23:52   
i didnt quite understand that, dude. Can you give an example?!? plox

(in reply to TexasWebDevelopers)
michaelea

 

Posts: 143
Joined: 11/9/2007
From: Cannon Beach, US West
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/17/2009 3:20:14   
quote:

ORIGINAL: C4RASHy

i didnt quite understand that, dude. Can you give an example?!? plox


<div id="clickablediv">Lorem Ipsum etc....
<div id="div2">More Latin....</div>
<div id="div3">Maybe some Gaelic now......</div>
<!-- comment: this closes the clickablediv --></div>

?

Not sure but I think that might have been what you were asking....

< Message edited by michaelea -- 5/17/2009 3:42:29 >


_____________________________

I wish I could design websites....
http://www.cannonbeachcomputers.com

(in reply to C4RASHy)
michaelea

 

Posts: 143
Joined: 11/9/2007
From: Cannon Beach, US West
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/17/2009 3:41:38   
and, how on earth does this post get fortytwoandahalfthousand hits ???

Is there that many people having JS visibility issues out there?????

_____________________________

I wish I could design websites....
http://www.cannonbeachcomputers.com

(in reply to phillipu)
C4RASHy

 

Posts: 5
Joined: 5/7/2009
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/17/2009 6:42:53   
I have 2 divs and one link.
Imagine:

---
Here is DIV1
Here is link
Here is DIV2
---

i want both div1 and div2 to get visible when I click the link

thank You

(in reply to michaelea)
michaelea

 

Posts: 143
Joined: 11/9/2007
From: Cannon Beach, US West
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/17/2009 6:51:54   

quote:

ORIGINAL: C4RASHy

I have 2 divs and one link.
Imagine:

---
Here is DIV1
Here is link
Here is DIV2
---

i want both div1 and div2 to get visible when I click the link

thank You


---------
Here starteth DIV1
Here is link
Here starteth DIV2
Here is DIV2 content
Here endeth DIV2
Here endeth DIV1
---------

Here endeth the lesson :)

_____________________________

I wish I could design websites....
http://www.cannonbeachcomputers.com

(in reply to C4RASHy)
C4RASHy

 

Posts: 5
Joined: 5/7/2009
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/17/2009 7:16:19   
I need:

Here is div1 content
Here is the link (outside any divs)
Here is div2 content

(in reply to michaelea)
michaelea

 

Posts: 143
Joined: 11/9/2007
From: Cannon Beach, US West
Status: offline

 
RE: javascript visibility toggle, always starts "v... - 5/17/2009 7:19:08   
Sorry I couldn't help...

_____________________________

I wish I could design websites....
http://www.cannonbeachcomputers.com

(in reply to C4RASHy)
Page:   [1]

All Forums >> Web Development >> General Web Development >> javascript visibility toggle, always starts "visible" instead of "hidden"
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts