SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Jan 2010
    Location
    Leeds
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    a href - Link - From ASP string

    Hi Guys,

    I am pulling in a Google Maps link into a page -

    response.write "Map" & " - " & trim(myRS("Google_Map_URL")) & "." & "<br/>" & vbCrLf

    I need to make a hyperlink that opens the map in a new browser window (target = blank) out of the above sting, can anyone help please as I can't get the syntaxt correct?

    Thank you,

    Dave.

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code:
    sURL=trim(myRS("Google_Map_URL"))
    response.write "Map - <a href=""" & sURL & """ target=""_blank"">" & sURL & "</a>.<br/>" & vbCrLf
    Not tested but should be close enough.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Member
    Join Date
    Jan 2010
    Location
    Leeds
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    Quote Originally Posted by siteguru View Post
    Code:
    sURL=trim(myRS("Google_Map_URL"))
    response.write "Map - <a href=""" & sURL & """ target=""_blank"">" & sURL & "</a>.<br/>" & vbCrLf
    Not tested but should be close enough.
    Great work Ian, thank you very much

  4. #4
    SitePoint Member
    Join Date
    Jan 2010
    Location
    Leeds
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ian,

    Could you give me some pointers on how I would code an image coming in from the database please?

    I have the place holder coded for it -

    response.write "<div id = imageHolder></div>"

    It's just the image name held in the database I will be pulling and appending to the file path on the server.

    Thank you,

    Dave.

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is all just handling strings in VBScript/ASP. For example:

    Code:
    sPath="path/to/images/"
    
    sImage=Trim(myRS("Image"))
    sDIV="<div id=""imageHolder""><img src=""" & sPath & sImage & """></div>"
    Response.write sDIV
    Ian Anderson
    www.siteguru.co.uk

  6. #6
    SitePoint Member
    Join Date
    Jan 2010
    Location
    Leeds
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Ian, I will try it out later and let you know how I get on.

    Dave.

  7. #7
    SitePoint Member
    Join Date
    Jan 2010
    Location
    Leeds
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Ian,

    I have this code in place -

    response.write "<div id = imageHolder>" & "<img src=""images/properties/"""&propImage&""" width="""&imageWidth&""" height="""&imageHeight&"""/>" & "</div>"

    Which is pulling the variables but it's adding a quote at the start of the image name variable in the html -

    <img src="images/properties/"test.jpg" width="212px" height="300px"/>

    <img src="images/properties/"test.jpg" width="212px" height="300px"/>
    Quote added here ---------------^

    Any ideas why?

    Thanks,

    Dave.

  8. #8
    SitePoint Member
    Join Date
    Jan 2010
    Location
    Leeds
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Ian,

    Just by way of an update, if I hard code the image path, it works fine.

    Thanks,

    Dave.

  9. #9
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    When doing Response.Write, you start the string to be written with " and end it with ". If you want to write a " inside the string (like <img src="whatever.jpg") you double it up, like "", so "<img src=""whatever.jpg""/>" in this example.

    If you then want to include the value as a variable (e.g. sImg = "whatever.jpg") then you need to close the string, append the variable, then open the string again. In our example here it would be:

    Response.Write "<img src=""" & sImg & """/>"

    When developing such strings, I find it easier to say to myself Open or Close for each " mark. The above string would read:

    Open ... Close Open Close ... variable ... Open Close Open ... Close

    Every string should start with an Open and end with a Close.

    In your case the problem is """ after properties/ ... this should just be " (""" writes a " whereas you simply want to close the string to append the variable).
    Ian Anderson
    www.siteguru.co.uk

  10. #10
    SitePoint Member
    Join Date
    Jan 2010
    Location
    Leeds
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cracked it Ian, thank you very much.

    Dave.


Bookmarks

Posting Permissions

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