I am trying to concatenate image url (string) with img tag but i am not sure how to put " after src=. Please help to concatenate this.
response.write("<img src=" & '"' & rs("ProductImage") & '"' &" /><br/>")
You have to double up the quotes:
Response.Write("<img src=""" & rs("ProductImage") & """ /><br/>")
Since HTML can use double quotes or single quotes, why not just use single quotes for the HTML. So your code would look like this:
response.write("<img src='" & rs("ProductImage") & "' /><br/>")
The resulting output would look like this:
<img src='ProductImageUrl' /><br/>
Another option is to use the chr function:
Response.Write("<img src=" & chr(34) & rs("ProductImage") & chr(34) & " /><br/>")
ascii code 34 is the double quote. We use this all the time when writing out HTML.
Related
I'm working on a rss feed reader and seems so work great.
The only thing that I seem not to get working is to read the image in the feed.
<itunes:image href="http://www.itunes.com/image.jpg"/>
Can anyone help?
This is a part of my code.
For Each objItem in objItems
On Error Resume Next
TheTitle = objItem.selectSingleNode("title").Text
TheLink = objItem.selectSingleNode("image").Text
Theimg = objItem.SelectSingleNode("itunes").Attributes(":image").InnerText
Response.Write "<div class='article'>" &_
"<a href=" & TheLink & ">" & _
"<span>" & Theimg & TheTitle & "</span>" & _
"</a>" & _
"</div>"
Next
Your image address needs to go inside an image tag
Response.Write "<div class=""article"">" &_
"<a href=""" & TheLink & """>" & _
"<img src=""" & Theimg & """ alt=""" & TheTitle & """ />" & _
"</a>" & _
"</div>"
If you're wondering why all the double quotes, see this question
Adding quotes to a string in VBScript
As an aside, if you understand XSL then I find that the best way to handle RSS feeds in Classic ASP is to do a server side XSLT transformation. The ASP looks like this
set xml = Server.CreateObject("Msxml2.DomDocument.6.0")
xml.setProperty "ServerHTTPRequest", true
xml.async = false
xml.validateOnParse = false
xml.load("http://your-rss-feed")
set xsl = Server.CreateObject("Msxml2.DomDocument.6.0")
xsl.load(Server.Mappath("yourxslfile.xsl"))
Response.Write(xml.transformNode(xsl))
set xsl = nothing
set xml = nothing
I am trying to return a link for the given text.
Here is the code:
<%
dim t
t = Request.QueryString("txt")
Response.Write("<a href = \" page2.html \" >" & t & "<\a>")
%>
Can anybody tell me what's wrong with the code?, it is not working.
To escape the " in vbscript, you have to double it. That is use "" for printing ".
Response.Write("<a href = "" page2.html "" >" & t & "<\a>")
Dim adoRecordset
Remark is the value saved in SQL
my html value is
value="<%=adoRecordset("Remark")%>">
so how could i add it into the " ??? "
response.Write VALUE='???'
Thanks Guys ~
I think this should do the trick for you:
Response.Write "<value='" & adoRecordset("Remark") & "' name='test'>"
Edit: My quick and lazy version, as done properly by Mr. Shadow Wizard
Response.Write("<input name=""test"" value=""" & Replace(adoRecordset("Remark"), """", """) & """ />")
How many " (double quotes) do I put around this line so that I end up with ="08075" being pasted into my excel worksheet? The line is:
Response.Write vbTab & ResultSet(8,r)
I need and '=' sign with a single quote before the ResultSet(8,r) with a closing double quote after... I tried:
Response.Write vbTab & "="" & ResultSet(8,r) & """
but that didn't work, plus a couple others but that didn't work, the number of quotes thing always gets me so if someone wants to give me a general rule of thumb on this one I would really appreciate it.
To get a literal double quote (") inside of a string in VBScript, you need to use two double quotes (""). So for your example:
Response.Write vbTab & "=""" & ResultSet(8,r) & """"
' ^ ^ ^ ^ These delimit the string
' ^^ ^^ These create literal quotes
Wouldn't you know, I just cracked it:
Response.Write vbTab & "=""" & ResultSet(8,r) & """"
Thanks, R.
Double each quote you want to end up in the string. So what you want would be:
Response.Write vbTab & "=""" & ResultSet(8,r) & """"
I'm debugging some ASP code and I need to get a quick printout of the current Request datastructure, which I believe is an array of key/value pairs.
I see that Request.Form("key") is the method for extracting individual elements.
Any tips on printing out the entire thing?
Try this
For Each item In Request.Form
Response.Write "Key: " & item & " - Value: " & Request.Form(item) & "<BR />"
Next
Working:
For x = 1 to Request.Form.Count
Response.Write x & ": " _
& Request.Form.Key(x) & "=" & Request.Form.Item(x) & "<BR>"
Next
I have other Classic ASP code snippets here:
https://github.com/RaviRamDhali/programming-procedure/tree/master/Snippets/ASP
Try a FOR/EACH loop:
for each x in Request.Form
Response.Write(x)
Next