...

View Full Version : syntax help (real basic)



sylvestermoy
08-14-2005, 07:17 AM
Howdy to the good people here at codingforums.com :)

I would like to know if someone could help. I have to remake a form, and wondering why if I change this code:

<%
if invalidsurname= true then
response.write "Surname:"
else
response.write "Surname:"
end if
%>

to this:

<div class="red_text">
<% if invalidsurname= true then response.write "Surname:" else %></div>
<div class="bold_text">Surname:</div><% end if %>

Why it doesn't work.. I get a 'expected statement' error on the /end if

Brandoe85
08-14-2005, 10:42 AM
Theres no 'end if' if you use a one liner, So i'd just do it like this:


<div class="red_text">
<%
if invalidsurname then
response.write "Surname:"
else
%>
</div>
<div class="bold_text"><b>Surname:<b></div>
<%
end if
%>


Good luck;

sylvestermoy
08-14-2005, 12:27 PM
Thanks for your reply :thumbsup:

What does a one liner mean?

miranda
08-14-2005, 06:09 PM
You are using VBScript. In VB and it's different variations there are two types of IF statements. Those with multiple lines and those on one line.
A multiple line if/then statement looks like this

If someCondition Then
someAction
End If
If there is alternative code to run if that condition isn't met (an else statement) then a multi line if/then/else would look like this

If someCondition Then
someAction
Else
someOtherAction
End If

Now if you prefer you can put it all on one line. If you do this you omit the End If statement at the end.

If someCondition Then someAction
or
If someCondition Then someAction Else someOtherAction

sylvestermoy
08-15-2005, 12:37 PM
thanks, thats cleared the haze. thanks for the help :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum