Reply
Problem with javascript in a tag
Old 11-17-2007, 11:03 AM Problem with javascript in a tag
pealo86's Avatar
Webmaster Talker

Posts: 650
Name: Matt
Location: England, north west
Trades: 0
I have a page which uses a hidden div, that can be made visible using a link. This then displays various information which can be changed using links within it.

But each time I click a link on the page, the div dissappears again!

here is the code in the a tag that Im using:

Code:
<a onclick="javascript:Show('overlay');" href="index.php?workId=1#img">Apollyon</a></li><li><a onclick="javascript:Show('overlay');" href="index.php?workId=2#img">jaadoo</a>
Is this code correct or am I missing something?
pealo86 is online now
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
When You Register, These Ads Go Away!
Old 11-17-2007, 02:09 PM Re: Problem with javascript in a tag
tripy's Avatar
Do not try this at home!

Posts: 3,433
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
You are just showing us the function call. It's useless, we need to see the complete function(s) to help you
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is online now
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 11-17-2007, 02:20 PM Re: Problem with javascript in a tag
pealo86's Avatar
Webmaster Talker

Posts: 650
Name: Matt
Location: England, north west
Trades: 0
oh! here is the code for the function

Code:
function hide(str) {
x = document.getElementById(str);
x.style.visibility = 'hidden';
}
function Show(str) {
x = document.getElementById(str);
x.style.visibility = 'visible';
}
pealo86 is online now
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 11-17-2007, 08:25 PM Re: Problem with javascript in a tag
chrishirst's Avatar
Super Moderator

Posts: 26,492
Location: Blackpool. UK
Trades: 0
Ok

soooo!

You click a link to show an element and with the same click reopen the page, what would be your guess at the problem?

__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | Crowded Nightclub? | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-18-2007, 07:26 AM Re: Problem with javascript in a tag
pealo86's Avatar
Webmaster Talker

Posts: 650
Name: Matt
Location: England, north west
Trades: 0
Yeah I know thats the problem, but do you know if theres a relatively easy solution to fixing it? Or would it be easier to just use a completely different method that doesn't involve a hidden div?
pealo86 is online now
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 11-18-2007, 08:00 AM Re: Problem with javascript in a tag
chrishirst's Avatar
Super Moderator

Posts: 26,492
Location: Blackpool. UK
Trades: 0
each time you open the page call the show() function.

Though to cover for UAs that have no javascript capabilities, the best way is to open the page with all hidden elements shown, then use a javascript call to hide them all, and show the default with an onload event.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | Crowded Nightclub? | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-18-2007, 10:37 AM Re: Problem with javascript in a tag
pealo86's Avatar
Webmaster Talker

Posts: 650
Name: Matt
Location: England, north west
Trades: 0
Thanks I'll keep that in mind
pealo86 is online now
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Reply     « Reply to Problem with javascript in a tag
 

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.10786 seconds with 13 queries