Jump to content

Special Characters in Response.Write statements


Striped Fish
 Share

Recommended Posts

Okay I'm working on converting HTML into ASP in Response.Write statements so first I ran into the problem with parentheses so I changed those to the ascii characters but they used the '#' symbol and ran into problems with that. So how do I write characters like # symbols? Here's my code. TIA

<%Response.Write("<tr><td bgcolor=""#1e1e1e"" class=""Stats-selected""><img class=""img"" src=""http://www.dragonkwest.net/dragonkwest/images/icons/stats.png""><span style=""font-weight:bold;color:white;"">Stats</span>          </td><td bgcolor=""#1e1e1e"" class=""non-selected-items""><a href=""?v=items""><img class=""img"" src=""http://www.dragonkwest.net/dragonkwest/images/icons/items.png""></img></td><td bgcolor=""#1e1e1e"" class=""non-selected-Combatabilities""><a href=""?v=attacks""><img class=""img"" src=""http://www.dragonkwest.net/dragonkwest/images/icons/combat-a.png""></img></a></td></tr></table><table cellpadding=""0"" cellspacing=""0"" width=""153px"" class=""list-bottom""><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")Response.Write("document.write(""Strength: "" + str + """);</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")Response.Write("document.write(""Magic Resist: "" + mgr + """);</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")Response.Write("document.write(""Parry: "" + parry + """);</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")Response.Write("document.write(""Melee: "" + melee + """);</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")Response.Write("document.write(""Dodge: "" + dodge + """);</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type="text/javascript">")Response.Write("document.write(""Armour: "" + armour + """);</script></center></td></tr>")%>

Edited by Glorfindal
Link to comment
Share on other sites

I using it because those variables are declared earlier in the javascript by and because those variables change they are retrieved from the Database. And maybe If I give you the presice error you'll understand because I could be misinterpreting it. Here is the error I am receiving:

Microsoft VBScript compilation error '800a03ea' Syntax error /testing.asp, line 3 Response.Write("document.write(""Strength: "" + str + """)</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")--------------------------------------------------------------^
And there really should be 2 ';' of these after the 41 but I had to take it away because it kep converting them into right parentheses. Edited by Glorfindal
Link to comment
Share on other sites

It's the number of quotes that it is confused about. You can thank VBScript for using more quotes to escape quotes, but I'll bold the actual string so you can see where the string ends:Response.Write("document.write(""Strength: "" + str + """);</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")It sees that code like this:

Response.Write("document.write(""Strength: "" + str + """);</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")

One line writes the text, and then there's a bunch of stuff that it doesn't know what to do with.

Link to comment
Share on other sites

Okay I got the computer to execute but the javascript is invalid: Here's the ASP Code

<%Response.Write("<tr><td bgcolor=""#1e1e1e"" class=""Stats-selected""><img class=""img"" src=""http://www.dragonkwest.net/dragonkwest/images/icons/stats.png""><span style=""font-weight:bold;color:white;"">Stats</span>          </td><td bgcolor=""#1e1e1e"" class=""non-selected-items""><a href=""?v=items""><img class=""img"" src=""http://www.dragonkwest.net/dragonkwest/images/icons/items.png""></img></td><td bgcolor=""#1e1e1e"" class=""non-selected-Combatabilities""><a href=""?v=attacks""><img class=""img"" src=""http://www.dragonkwest.net/dragonkwest/images/icons/combat-a.png""></img></a></td></tr></table><table cellpadding=""0"" cellspacing=""0"" width=""153px"" class=""list-bottom""><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")Response.Write("document.write(""Strength: "" + str + "");</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")Response.Write("document.write(""Magic Resist: "" + mgr + "");</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")Response.Write("document.write(""Parry: "" + parry + "");</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")Response.Write("document.write(""Melee: "" + melee + "");</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")Response.Write("document.write(""Dodge: "" + dodge + "");</script></center></td></tr><tr><td bgcolor=""#444444""><center><script type=""text/javascript"">")Response.Write("document.write(""Armour: "" + armour + "");</script></center></td></tr>")%>

And here's what it returns to the browser.

<tr><td bgcolor="#1e1e1e" class="Stats-selected"><img class="img" src="http://www.dragonkwest.net/dragonkwest/images/icons/stats.png"><span style="font-weight:bold;color:white;">Stats</span>          </td><td bgcolor="#1e1e1e" class="non-selected-items"><a href="?v=items"><img class="img" src="http://www.dragonkwest.net/dragonkwest/images/icons/items.png"></img></td><td bgcolor="#1e1e1e" class="non-selected-Combatabilities"><a href="?v=attacks"><img class="img" src="http://www.dragonkwest.net/dragonkwest/images/icons/combat-a.png"></img></a></td></tr></table><table cellpadding="0" cellspacing="0" width="153px" class="list-bottom"><tr><td bgcolor="#444444"><center><script type="text/javascript">document.write("Strength: " + str + ");</script></center></td></tr><tr><td bgcolor="#444444"><center><script type="text/javascript">document.write("Magic Resist: " + mgr + ");</script></center></td></tr><tr><td bgcolor="#444444"><center><script type="text/javascript">document.write("Parry: " + parry + ");</script></center></td></tr><tr><td bgcolor="#444444"><center><script type="text/javascript">document.write("Melee: " + melee + ");</script></center></td></tr><tr><td bgcolor="#444444"><center><script type="text/javascript">document.write("Dodge: " + dodge + ");</script></center></td></tr><tr><td bgcolor="#444444"><center><script type="text/javascript">document.write("Armour: " + armour + ");</script></center></td></tr>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...