Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

If statement

Options
  • 19-05-2008 4:36pm
    #1
    Registered Users Posts: 224 ✭✭


    Hi,

    I need the following statement to link a site if the statement is false, what code do i need to add?


    <td rowspan="3" bgcolor="#FFFFFF">
    <%
    Dim strQABCImage
    Dim vbtn
    vbtn=false
    If rsSearchRes.Fields("SupplierId").Value = "ABC" Then
    vbtn=true
    End If
    If vbtn=false then
    strQABCImage="../siteimgs/white_dot.gif"
    Else
    strQABCImage="../siteimgs/mqs_hdr.gif"
    End If

    %>
    <img src="<%=strQAMCImage%>" border="0"></td>


Comments

  • Registered Users Posts: 4,287 ✭✭✭NotMe


    If vbtn=false then

    I don't know what language that is but I'm guessing you want:
    If vbtn==false then
    


  • Registered Users Posts: 2,379 ✭✭✭toiletduck


    VBScript?


  • Registered Users Posts: 901 ✭✭✭EL_Loco


    I think it's ASP and you don't need "==" in that.

    declare another variable and set it to an address if your statement is false.

    You can have multiple statements between the start and end of your if statement. you seem to have a single if statement for everything you want to check, but that's beside the point.

    set the variable then output it into a <a href> tag. (which will create a link).

    does the code you've supplied work for the image?


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    It looks like classic asp to me and if so he doesn't need ==. OP what do you mean by link a site? Are you asking for a hyperlink to be displayed or for the page to redirect the user to another site.


  • Registered Users Posts: 224 ✭✭The Mighty Dubs


    Evil Phil wrote: »
    It looks like classic asp to me and if so he doesn't need ==. OP what do you mean by link a site? Are you asking for a hyperlink to be displayed or for the page to redirect the user to another site.


    Its classic Asp alright. I just the image to be hyperlinked to a site if the statement is false.


  • Advertisement
  • Registered Users Posts: 901 ✭✭✭EL_Loco


    you want to create a string that has the image wrapped in a <a href> tag.
    Here's what the html should look like:
    <a href="www.boards.ie"><img src="../siteimgs/white_dot.gif"></a>
    

    at this point in your code..
    If vbtn=false then
    strQABCImage="../siteimgs/white_dot.gif"
    
    ... you should construct the full string, I'm not well up on asp so maybe someone could help you with escape characters and things so when you want to enter double quotes in the string you're not actually closing the string.


  • Registered Users Posts: 893 ✭✭✭I.S.T.


    OP, I think you need to clarify exactly you are trying to do. I am confused and I think the others are also. Do you want to make the image into a link if vbtn is false?


  • Registered Users Posts: 224 ✭✭The Mighty Dubs


    OP, I think you need to clarify exactly you are trying to do. I am confused and I think the others are also. Do you want to make the image into a link if vbtn is false?



    sorry all,

    that is correct I want to make the image into a link if vbtn is indeed false.


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    sorry all,

    that is correct I want to make the image into a link if vbtn is indeed false.

    I would recommending putting as much of your server side code at the top of the page so you can separate the logic and markup as much as possible.

    I've simplified the ASP a little, but if you're using the variables in other locations, this may not help.
    <&#37;
    Dim strQABCImage
    strQABCImage = "<img src='../siteimgs/white_dot.gif' border='0'>"
    
    If rsSearchRes.Fields("SupplierId").Value = "ABC" Then  strQABCImage="<a href='yourpage.asp'><img src='../siteimgs/white_dot.gif' border='0'></a>"
    %>
    <%=strQAMCImage%>
    


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    any joy OP?


  • Advertisement
Advertisement