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.
Page 1 of 3 123 LastLast
Results 1 to 15 of 36
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IF Statment question, i think?

    hi, i have this course list which shows course info etc..

    in one of the sections my code is
    The course is currently set to run at <%=objRS("Venue")%> - so its html text and then the venue from the database.

    my problem is that if a courses venue is undecided the venue is written as TBC. (to be confirmed) and so the sentence The course is currently set to run at TBC - doesnt make sense.

    can i have it so if <%=objRS("Venue")%> = TBC show some other text - for example 'The venue is TBC'

    any ideas? thanks

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    not quite sure what u mean,,

    well if TBC is really in the data feild then just:


    <%
    if objRS("Venue") = "TBC" then
    response.write "some text"
    else
    response.write "some other text"
    end if
    %>

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks, thats excellent - but how can you add the venue detail into the code?

    i tried..

    <%
    if objRS("Venue") = "TBC" then
    response.write "Sorry this venue is currently set to objRS("Venue")"
    else
    response.write "This venue is due to run at objRS("Venue")"
    end if
    %>

    but it didnt work! thanks

  • #4
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use this:-

    Code:
    <%
    if objRS("Venue") = "TBC" then
    response.write "Sorry this venue is currently set to " & objRS("Venue")
    else
    response.write "This venue is due to run at " & objRS("Venue")
    end if
    %>
    Rob

  • #5
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks!

    very helpful !

  • #6
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what about a date?

    how could i make it so if <%=objRS("Date")%> was 'Todays date' it would say today instead of the date...

    thanks

  • #7
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    well, how are you storing the date in the db?
    it's it in a date feild and what format?

    u could do:

    If objRS("Date")=DATE() Then
    response.write "Today"
    else
    response.write "something else"
    end if

  • #8
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can you add a link in this code?

    If objRS("Date")=DATE() Then
    response.write "Today"
    else
    response.write "something else <a href="something.asp" class="more">click</a>
    end if

    ??

    thanks

  • #9
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    yup,
    just make sure u include a closing quote on the responce.write
    and double quotes on =""something.asp""


    If objRS("Date")=DATE() Then
    response.write "Today"
    else
    response.write "something else <a href=""something.asp"" class=""more"">click</a>"

  • #10
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if i have a value 'strSearch' how do i use this in a IF statement?

    so far i got :

    <%
    if strSearch = "%" then
    response.write "You have chosen to view all results."
    else
    response.write "Your search for " & "strSearch" returned " & "iRecordCount" Companies."
    end if
    %>

    the one that says 'You have chosen to view all results.' works but the other shows 'strSearch' instead of the actual word that was searched for.

    any ideas?

    thanks

  • #11
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Don't put it in quotes if it's a variable.
    Code:
    response.write "Your search for " 
                        & strSearch 
                        & " returned " 
                        & iRecordCount 
                        & " Companies."
    It should be in one line, I put it in multiple lines for readability. It seems you're confused on concatenating strings with variables.

  • #12
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    whats wrong with this!!

    Code:
    <%
    if objRS("Filename") = "" then
    response.write "<img src=""images/nologo.gif"">"
    else
    response.write "<img src=""images/" & objRS("Filename").gif""">"
    end if
    %>
    wont work!!
    Web and Business Development from Cornwall - Startbar.co.uk

  • #13
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Help please!

    <%=objRS("Filename")%> is the entry for the persons filename. so i use

    <img src="images/<%=objRS("Filename")%>.gif" border="0"> to show them.

    however when the person has no image how do i get it to show a nologo.gif

    i tried with this if statement but doesnt work!!

    Code:
    <%
    if objRS("Filename") = "" then
    response.write "<img src=""images/nologo.gif"">"
    else
    response.write "<img src=""images/companylogos/" & objRS("Filename") & ".gif"">"
    end if
    %>
    Web and Business Development from Cornwall - Startbar.co.uk

  • #14
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Try this:
    Code:
    <%
    dim fileName
    fileName = objRS("Filename")
    response.write "filename:" & fileName & "<br />" 'debug
    if fileName = "" or IsNull(fileName) then
      response.write "<img src=""images/nologo.gif"">"
    else
      response.write "<img src=""images/companylogos/" & fileName & ".gif"">"
    end if
    %>

  • #15
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how do i get it so it doesnt say the filename as well?

    thanks, tho that is excellent
    Web and Business Development from Cornwall - Startbar.co.uk


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

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