Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

Re: FN-FORUM: Javascript problem (another one!)

date posted 9th August 2003 11:50

hi nita,

everything looks fine with your code, and yes, the onClick version you
have below would work - the only thing you have missed are some
quotemarks around the name of the layer you are trying to show/hide...
so your piece of code should read:

Link 4

where the DIVs are named as such in the CSS i.e. #linkone { blah blah }

and then called in the HTML like something in
here

if you wanted to further optimise the code, you could create a variable
called 'layerFlag' each time the function is called, so that you don't
have to cycle through all the layers to turn them off each time, the
code would always know the last layer that was made visible.

this would work like this (assuming that the layer 'linkone' was
visible on loading the page, but it doesn't really matter, you just
have to set the variable up with something before using it :-)



var layerFlag = 'linkone';

function swapIt(thisone) {

if (thisone == layerFlag) return;

document.all[layerFlag].style.visibility = 'hidden';
document.all[thisone].style.visibility = 'visible';

layerFlag = thisone;

}




and then in your HTML you would simply need:

Link 4


i have added the line: if (thisone == layerFlag)... this just quits
the user from the function if they happen to click a link to a layer
that is already visible, so that they don't see a flash as the same
layer disappears and reappears again!


HTH!
luke



On Friday, August 8, 2003, at 09:04 PM, Nita wrote:

> Hi Luke, I was trying out the script you sent and I'm not sure if I'm
> using
> it properly...
>
>
> I've put the function in and I have the following mouseovers and outs:
>
>
> onMouseout="swapOut(textrhs);
> ">Introduction
> onMouseout="swapOut(linkone);
> ">How does this on-line course work?
> onMouseout="swapOut(linktwo);">Registration Form
> onMouseout="swapOut(linkthree);">Study Plan
> onMouseout="swapOut(linkfour)">Link 4
>
> Each time I hover I get:
>
> document.all[...].style is null or not an object
>
> I'm afraid I can't see where I'm making a mistake....
>
> Also, I wanted to show the divs onClick - I was getting the same error
> and
> being diverted to my folder and it was bugging me so I changed it for
> ease
> of testing! But it also occured to me that I would need to swapout
> each div
> something like this:
>
> swapOut(linktwo);
> swapOut(linkone);">Link 4
>
> Would this make sense? I couldn't tell if it would have worked
> because I
> was getting the same error as above....
>
> Can you shed any light on it?
>
> Very much appreciated if you can!
>
> Nita
> ;o)



Messages by Day
August 31st 2003
August 30th 2003
August 29th 2003
August 28th 2003
August 27th 2003
August 26th 2003
August 25th 2003
August 24th 2003
August 23rd 2003
August 22nd 2003
August 21st 2003
August 20th 2003
August 19th 2003
August 18th 2003
August 17th 2003
August 16th 2003
August 15th 2003
August 14th 2003
August 13th 2003
August 12th 2003
August 11th 2003
August 10th 2003
August 9th 2003
August 8th 2003
August 7th 2003
August 6th 2003
August 5th 2003
August 4th 2003
August 3rd 2003
August 2nd 2003
August 1st 2003


Messages by Month
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003


Messages by Year
2009
2008
2007
2006
2005
2004
2003
2002
2001
2000