Solved

elseif syntax?

Posted on 2012-03-27
6
331 Views
Last Modified: 2012-04-30
Can someone please help me understand why this gives me an error and how to correct it?

<iframe name="main" width="89%" height="100%" align="right" frameborder="0" style="background-color:#FFFFFF; overflow:hidden;" src="<% If Request.querystring("loadCurrent") = 1 Then Response.write "EditCurrent.asp" ElseIf Request.querystring("loadCurrent") = 2 Then Response.write "main.htm" Else Response.write "main.htm" End If %>"></iframe>

Open in new window


ERROR:
Microsoft VBScript compilation error '800a0401' 

Expected end of statement 

/corpcardnew/Default.asp, line 64 

If Request.querystring("loadCurrent") = 1 Then Response.write "EditCurrent.asp" ElseIf Request.querystring("loadCurrent") = 2 Then Response.write "main.htm" Else Response.write "main.htm" End If
--------------------------------------------------------------------------------^

Open in new window

0
Comment
Question by:Ahelbling
6 Comments
 
LVL 7

Expert Comment

by:Lalit Chandra
ID: 37773085
Remove   Response.write.
i mean replace the line
 Response.write "EditCurrent.asp"
with only
"EditCurrent.asp"
0
 

Author Comment

by:Ahelbling
ID: 37773098
that didnt seem to work...


Microsoft VBScript compilation error '800a0400'

Expected statement

/corpcardnew/Default.asp, line 64

If Request.querystring("loadCurrent") = 1 Then "EditCurrent.asp" ElseIf Request.querystring("loadCurrent") = 2 Then "main.htm" Else "main.htm" End If
-----------------------------------------------^
0
 

Author Comment

by:Ahelbling
ID: 37773102
are the double quotes around "EditCurrent.asp"  possibly breaking this?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

Accepted Solution

by:
Big Monty earned 167 total points
ID: 37773212
i would write out the code like this, its a lot more readable:

<% 
If Request.querystring("loadCurrent") = 1 Then 
    src = "EditCurrent.asp" 
ElseIf Request.querystring("loadCurrent") = 2 Then 
    src = "main.htm" 
Else 
    src = "main.htm" 
End If 
%>

<iframe name="main" width="89%" height="100%" align="right" frameborder="0" style="background-color:#FFFFFF; overflow:hidden;" src="<%=src%>" ></iframe>

Open in new window

0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 166 total points
ID: 37773289
VBscript wants it to be a multi-line coding like The_Big_Daddy shows above.  The end of line means something to the VBscript parser and it's missing when you try to put it all on one line like you have.  That's what the error "Expected end of statement " in your original post is referring to.
0
 
LVL 5

Assisted Solution

by:Seonyx
Seonyx earned 167 total points
ID: 37775586
You can separate commands on one line with a colon. Also good practice to only call your request variable once. Use the select case statement as it is more suitable in this situation. Try this:
<iframe name="main" width="89%" height="100%" align="right" frameborder="0" style="background-color:#FFFFFF; overflow:hidden;" src="<% Dim loadcurrentresponse:loadcurrentresponse = Request.querystring("loadCurrent"):select case loadcurrentresponse:case "1":response.write("EditCurrent.asp"):case else:response.write("main.htm"):End select%>"></iframe>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now