Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    syntax help (real basic)

    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

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Theres no 'end if' if you use a one liner, So i'd just do it like this:
    Code:
    <div class="red_text">
    <%
    if invalidsurname then
    	response.write "Surname:"
    else
    %>
    	</div>
    	<div class="bold_text"><b>Surname:<b></div>
    <%
    end if
    %>
    Good luck;

  • #3
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your reply

    What does a one liner mean?
    Last edited by sylvestermoy; 08-14-2005 at 12:46 PM.

  • #4
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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
    Code:
    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
    Code:
    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.
    Code:
    If someCondition Then someAction
    or 
    If someCondition Then someAction Else someOtherAction

  • #5
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks, thats cleared the haze. thanks for the help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •