Home  >  Article  >  Web Front-end  >  html splicing problem_html/css_WEB-ITnose

html splicing problem_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:12:481096browse

I don’t know much about web development, but I need to modify some asp things. When I spell html, I always make mistakes, sometimes "sometimes' sometimes&", I feel dizzy. I know the main reason is that I am not very good at this aspect. I understand, but the writing style of html and javascript is too "loose" or too loose, unlike C#.
There is a statement that cannot be spelled. Help:
is a statement that dynamically outputs query results. rs is the result. Set

Response.Write"<table align=center bgcolor='#666666' border=0 cellpadding=1 cellspacing=0 ><tbody><td><a href='a.asp?id="&rs("id")&"' target='_blank'><img src="&rs("id")&" border='0' width=160 height=160 onmouseover=showBigImg(<img src="&rs("img")&">) onmouseout=showBigImg() ></a></td></tbody></table><br><a href='a.asp?id="&rs("id")&"' target='_blank'>"&rs("name")&"</a></td>"

The main problem is here. This part was added. It was no problem before. Now I need to add a function to display a large picture after the mouse is passed, but there is a syntax error in the html splicing
onmouseover=showBigImg(<img src="&rs("img")&">) onmouseout=showBigImg()


Reply to the discussion (solution)

Response.Write"<table align=center bgcolor=\"#666666\" border=0 cellpadding=1 cellspacing=0 ><tbody><td><a href=\"a.asp?id=\"&rs(\"id\")&\"\" target=\"_blank\"><img src=\"&rs(\"id\")&\" border=\"0\" width=160 height=160 onmouseover=showBigImg(<img src=\"&rs(\"img\")&\">) onmouseout=showBigImg() ></a></td></tbody></table><br><a href=\"a.asp?id=\"&rs(\"id\")&\"\" target=\"blank\">\"&rs(\"name\")&\"</a></td>";

Try to use " uniformly. "Use escape...

You can define a variable to receive the string... Then output this variable... See where there is a problem

dim a=rs("id");dim b=rs("img");dim c=rs("name");Response.Write "<table align=center bgcolor='#666666' border=0 cellpadding=1 cellspacing=0 ><tbody><td><a href='a.asp?id="+a+"'target='_blank'><img src='' border='0' width=160 height=160 onmouseover=showBigImg(<img src='"+b+"'>) onmouseout=showBigImg() ></a></td></tbody></table><br><a href='a.asp?id="+a+"' target='blank'>"+c+"</a></td>";

All Try it

The connection of vbscript is &
For example

response.write("870b60f24805d6a55f430c61947111c3"&rs("col")&" 16b28748ea4df4d9c2150843fecfba68")
or
response.write("b350fb13c513d0e7780ea7a547441973"&rs("col")&"16b28748ea4df4d9c2150843fecfba68")

The poster can check the source code of the page and see the difference

'color:red' prints out as single quotes

""color:red""> prints out as single quotes pair of double quotes

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn