Dynamic Include files

J

JP SIngh

Hi All

I want to include javascript files based on the user location which I store
in a session variable upon user login.

The original code was like this

<SCRIPT language=JavaScript src="test_files/calcholidays.js"></SCRIPT>

We have multipe Javascript Script files and want to use the correct one
based on the Location Variable.

The variable is sLocation = Session("Location")

We would like the include file to look something like this

<SCRIPT language=JavaScript src="test_files/" & <%= sLocation %> &
".js"></SCRIPT>

Not sure how to write this.

Can someone please help
 
E

Evertjan.

JP SIngh wrote on 15 nov 2004 in
microsoft.public.inetserver.asp.general:
I want to include javascript files based on the user location which I
store in a session variable upon user login.

The original code was like this

<SCRIPT language=JavaScript src="test_files/calcholidays.js"></SCRIPT>

We have multipe Javascript Script files and want to use the correct
one based on the Location Variable.

The variable is sLocation = Session("Location")

We would like the include file to look something like this

<SCRIPT language=JavaScript src="test_files/" & <%= sLocation %> &
".js"></SCRIPT>

Not sure how to write this.

Can someone please help

Please next time start with:

Did you try this out?
Did you look at the rendered source in your browser?
Was it succesfull? If not, dit you get an error [what error]?

==================

Try, after analyzing the differences with your code:

<SCRIPT type="text/javascript"
src="test_files/<% =Session("Location") %>.js">
</SCRIPT>

And inspect the rendered html again.
 
J

JP SIngh

Yes I did try it out sir but it did not work.

I don't know the syntax hence my question.

Thanks you
Evertjan. said:
JP SIngh wrote on 15 nov 2004 in
microsoft.public.inetserver.asp.general:
I want to include javascript files based on the user location which I
store in a session variable upon user login.

The original code was like this

<SCRIPT language=JavaScript src="test_files/calcholidays.js"></SCRIPT>

We have multipe Javascript Script files and want to use the correct
one based on the Location Variable.

The variable is sLocation = Session("Location")

We would like the include file to look something like this

<SCRIPT language=JavaScript src="test_files/" & <%= sLocation %> &
".js"></SCRIPT>

Not sure how to write this.

Can someone please help

Please next time start with:

Did you try this out?
Did you look at the rendered source in your browser?
Was it succesfull? If not, dit you get an error [what error]?

==================

Try, after analyzing the differences with your code:

<SCRIPT type="text/javascript"
src="test_files/<% =Session("Location") %>.js">
</SCRIPT>

And inspect the rendered html again.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)
 
B

Bob Barrows [MVP]

JP said:
Hi All

I want to include javascript files based on the user location which I
store in a session variable upon user login.

The original code was like this

<SCRIPT language=JavaScript src="test_files/calcholidays.js"></SCRIPT>

We have multipe Javascript Script files and want to use the correct
one based on the Location Variable.

The variable is sLocation = Session("Location")

We would like the include file to look something like this

<SCRIPT language=JavaScript src="test_files/" & <%= sLocation %> &
".js"></SCRIPT>

Not sure how to write this.
To start with: don't use a vbscript concatenation expression when you've
specified the language to be javascript. Use +, not &.

Bob Barrows
 
A

Aaron [SQL Server MVP]

<SCRIPT language=JavaScript src="test_files/" & <%= sLocation %> &
".js"></SCRIPT>

Maybe you meant:

<SCRIPT language=JavaScript src="test_files/<%= sLocation %>.js"></SCRIPT>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top