PDA

View Full Version : Giving different nav menus to different users (depending on zip code)


mgrice
04-19-2003, 09:47 PM
Scenario:
User enters a Zip Code on the first screen. Based on that entry, the Navigation Menu they see/use throughout the site is different.

I have the Menuing routine worked out with separate Javascript/CSS values in 30 different menu data file.

I *thought* the syntax would look something like this:

If (String(Request.QueryString("sid")) = 12345){
<script language="JavaScript1.2" src="navmenu_alpha.js"></script>
}

If (String(Request.QueryString("sid")) = 23456){
<script language="JavaScript1.2" src="navmenu_baker.js"></script>
}

If (String(Request.QueryString("sid")) = 34567){
<script language="JavaScript1.2" src="navmenu_charlie.js"></script>
}

But I cannot get it to go. I have tried putting quotes around the zip code, but that was not it.


Is such a function possible? Am I close with this? Or do I need to look at another way?

Any help, hand-holding, tutorials, etc. would be greatly appreciated. I hope I have sufficiently described everything.

Thanks.

Philip M
04-20-2003, 07:50 AM
Try

document.write(<script language="JavaScript1.2" src="navmenu_charlie.js"></script>)

mgrice
04-20-2003, 02:27 PM
What you suggsted WORKED, with this lingering problem: It writes the text of the line in what is displayed (example: "if(rsContent_MMColParam = 18940) document.write( )"

Here is an actual link:
http://www.gardensplendor.com/gs2003/18940main.asp?pid=cc_main

Is there a way to suppress this from appearing?

THANKS for the help!

Philip M
04-20-2003, 03:40 PM
You have got a couple of unwanted carriage returns, and the comparison operator should be == e.g. if (x==1), not = which is the assignment operator (e.g. a=b):-

if(rsContent_MMColParam = 18940) document.write(
<script language="JavaScript1.2" src="navmenu_caro.js"></script>
)

Try changing it to

if(rsContent_MMColParam == 18940) {document.write(<script language="JavaScript1.2" src="navmenu_caro.js"></script>)}

The curly braces may not be required, but cannot do any harm!

mgrice
04-20-2003, 05:29 PM
That still did not fix it.

But I greatly appreciate the suggestion. And also the clarification on using ==, rather than a single =. This helps me understand better.

I guess it is just one of those things that this will not work. It seems like it should. But it doesn't.

At least it's nice to know it cannot be done, rather than I did not know how to do it.

THANKS again for all the help, suggestions and tutoring!

Philip M
04-20-2003, 05:49 PM
Perhaps someone more knowledgeable than I am will throw some light on it. Suggest you come back after the Easter vacation! But I think it ought to work with a bit of tweaking.


A workaround (or kludge) is to have just the one .js file and then


if (sid==12345) {
doallthis;
}
if (sid==23456) {
doallthat;
}
if (sid==34567) {
dosomethingelse;
}

and so forth.

I appreciate that this could make a heavyweight .js file and be a bit inefficient as to loading.