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!

Using variable in Javascript to populate the value of a 2nd variable

Status
Not open for further replies.

rexolio2008

Technical User
Apr 24, 2008
41
US
I have a javascript include file I received from a third party (web analytics) that has a variable in it called s.PageName. This variable is dymanically generated.

On the actual page that is being tracked, after the above javascript file is referenced, there's some on page javascript. One of the variables there is s.prop1.

I can enter the value for it by hand, but I actually need it to mirror the value for s.PageName (don't get caught up in the "why", as its too long to explain.)

So what I'd like to do, in effect, is say:

s.prop1 = s.PageName, but obviously that won't work. I literally need the value to be put there.

Any ideas? Impossible? Am a moron... er... off base? :)
 
s.prop1 = s.PageName, but obviously that won't work. I literally need the value to be put there.

I don't see why what you've tried won't work. If "s.PageName" contains your page name, and you want that same page name in "s.prop1", then "s.prop1 = s.PageName" will work.

If it's not working for you, perhaps:

- "s.PageName" isn't populated at the time you're assigning it to "s.prop1"

- You have an error in your syntax

- Something else is going wrong ;-)

Do you have a URL you can post?

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top