Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 if/then/else inside an Array (Javascript)
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 25 October 2001 :  03:27:37  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
I'm no genius in javascript, but I'm implementing a DHTML menu code into my site, and want to know if Its possible to put an if/then/else into an array... and what the proper syntax would be. Code I want is below, ASP code is red Note: The red ASP code in the javascript is what I WANT to say, only I want to say it in javascript, not asp


//Defining Javascript variables from asp

<%
If not(Trim(MemberID) = "") or not(MemberID = 0) then
response.write("var ARC_Loggedin = ""true""" & vbcrlf)
else
response.write("var ARC_Loggedin = ""false""" & vbcrlf)
End if
%>


[blue]
<Script Language="Javascript">
//Script starts.... yata yata

HM_Array2_1 = [
[],
If ARC_Loggedin = "false" then
["Login","login.asp",1,0,0],
["Register","policy.asp",1,0,0],
else
["Logout","logout.asp",1,0,0],
End if
//the script goes on...
</Script>


----------------
Da_Stimulator
Need a Mod?
My Snitz Test Center

HuwR
Forum Admin

United Kingdom
20585 Posts

Posted - 25 October 2001 :  04:01:24  Show Profile  Visit HuwR's Homepage
Not like you are attempting.

1) to use an asp variable in Jscript simply use an <%= %> tag ie
in jscript
if ('<%=Myvar%>' = 'test')

2) to constract an if then in jscript, the syntax is

if (...)
{......}
else
{......}

3) I'm pretty sure you can't use if then inside an array construct, you will need to use the if then to define seperate array elements.

Go to Top of Page

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 25 October 2001 :  04:07:29  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
Ok, thx huwr, so I would have to do something like this...

if (ARC_Loggedin == "true")
{
Entire Array Here
}
else
{
Entire Alternate Array Here
}

----------------
Da_Stimulator
Need a Mod?
My Snitz Test Center
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20585 Posts

Posted - 25 October 2001 :  04:11:43  Show Profile  Visit HuwR's Homepage
if Arc_loogedin is an ASP variable you would do this

if ('<%=ARC_Loggedin%>' == "true")
{
Entire Array Here
}
else
{
Entire Alternate Array Here
}



Go to Top of Page

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 25 October 2001 :  04:17:20  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
Ok thx Huw :)

----------------
Da_Stimulator
Need a Mod?
My Snitz Test Center
Go to Top of Page

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 26 October 2001 :  04:50:40  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
btw, I cant use the asp variable in that form, as the javascript is included via <script src="whatever.js"> - So I define the ARC_Loggedin variable in inc_top.asp before I call the js files, that way its there and defined.

----------------
Da_Stimulator
Need a Mod?
My Snitz Test Center
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07