Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax problem with variables & strings in a function

Status
Not open for further replies.

Boblevien

Technical User
Nov 3, 2000
38
GB
I’m trying to pass a variable into a function but can’t find the right syntax:

I have a number of image sources called nav1.src, nav2.src, nav3.src etc

I want to use something like the following function to change them around

function navigate(n) {
document.circles.src=”nav” + n + “.src”;
}

Can anyone help?

Bob Levien.
 
use Eval function:

function navigate(n) {
document.circles.src=eval(”nav” + n + “.src”);
}

Andrew | starway@mail.com
 
That's great - works a treat. Thanks a lot.

I don't suppose <pushing it> you have a solution to my previous question about why it doesn't work in Netscape? </pushing it>

Bob.
 
it's because of &quot;document.circles.src&quot; - it's not the way netscape (netscape 6- !!!) adresses elements
layers.circle.src, or document.all[circles].src or i don't rememeber, but this has been discussed here many times, you should use the &quot;search&quot; function here !!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top