Solved

elseif syntax?

Posted on 2012-03-27
6
330 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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 82

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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 code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

708 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

15 Experts available now in Live!

Get 1:1 Help Now