PDA

View Full Version : nested if-else conditional statements


lifang
09-17-2004, 05:35 AM
I am not too sure wats wrong w the if-else statement below! :confused:

<%if(grp==grp2)%>
{
<%if (start==req || end==req)%>
{
<%=grp%>
<%=start%>
<%=end%>
}
<%else%>
{
<%="There is no such record found"%>
}
}
<%else%>
{
<%="There is no such record found!"%>
}
<%endif%>

Error: 'else' without 'if'.
else
^

Thanks 4 e help

glenngv
09-17-2004, 07:31 AM
<%
if(grp==grp2)
{
if (start==req || end==req)
{
%>
<%=grp%>
<%=start%>
<%=end%>
<%
}
else
{
%>
<%="There is no such record found"%>
<%
}
}
else
{
%>
<%="There is no such record found!"%>
<%
}
%>

Actually, you can avoid those bunch of <% and %>

<%
if(grp==grp2)
{
if (start==req || end==req)
{
Response.Write(grp);
Response.Write(start);
Response.Write(end);
}
else
{
Response.Write("There is no such record found");
}
}
else
{
Response.Write("There is no such record found!");
}
%>

lifang
09-17-2004, 09:10 AM
i tried ur codings, but there are errors related to catch, try and finally
But anyway thanks 4 ur help! :thumbsup:

glenngv
09-17-2004, 12:10 PM
Could you post the try...catch...finally block? Is this really a Javascript server-side ASP script as I have assumed? Or is it JSP?