Solved

elseif syntax?

Posted on 2012-03-27
6
334 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 33

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

830 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