Jump to content

Special Characters in Response.Write statements


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 post
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 post
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 post
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 post
Share on other sites

<script type="text/javascript">document.write("Strength: " + str + ");</script>What's that extra quote doing at the end? Are the variables you're trying to print in the Javascript code defined somewhere else on the page?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...