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
Problems with hide/display div after reloading the page
Old 12-13-2009, 10:10 AM Problems with hide/display div after reloading the page
Junior Talker

Posts: 3
Trades: 0
In my site I've added this js script that show hides two different <div>, in fact when one is displayed, and the second hidden and vice-versa.

<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
function toggle_visibility2(id) {
var e = document.getElementById(id);
if(e.style.display = 'none')
e.style.display == 'block';
else
e.style.display = 'block';
}
//-->
</script>

These are the links from which the js is activated (they're part of the two different <div>).

<a href="#LinkArea1" name=Area1 onclick="toggle_visibility2('primasezione'); toggle_visibility('secondasezione');">Link1</a>

<a href="#LinkArea2" name=Area2 onclick="toggle_visibility('primasezione'); toggle_visibility2('secondasezione');">Link2</a>

My problem is that both are placed in a page that is auto-reloaded after 60 seconds, and when the second <div> is shown (and the first hidden), the page is reloaded with the first <div> visible and the second hidden, even if the user has used the link to close the first and display the other. There is any way to show the one selected at the moment of the refresh? Thank you for any help.
Emily22 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-13-2009, 03:17 PM Re: Problems with hide/display div after reloading the page
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Save the "active" element in a cookie the read it back when the page (re)opens
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-14-2009, 06:54 AM Re: Problems with hide/display div after reloading the page
Junior Talker

Posts: 3
Trades: 0
I've not a good knowledge of js, how can I register a session with a cookie and have it recognized by the page after reloading?
Emily22 is offline
Reply With Quote
View Public Profile
 
Old 12-14-2009, 06:55 AM Re: Problems with hide/display div after reloading the page
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://www.elated.com/articles/javascript-and-cookies/

http://www.w3schools.com/JS/js_cookies.asp
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-16-2009, 12:09 PM Re: Problems with hide/display div after reloading the page
Junior Talker

Posts: 3
Trades: 0
Thank you for the suggestion, i will add the necessary lines to the script
Emily22 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problems with hide/display div after reloading the page
 

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.78736 seconds with 12 queries