PDA

View Full Version : debug.write with "


Grig
03-29-2003, 11:24 AM
I was trying to write a " out to the debugger for a dev tool I made. If the tool could spit out formatted XML, then I could cut and paste the text.


I want generate to something like this:
x="12"

When I use:
debug.write('x='+"+XVAL+");

it outputs everything between the " as literal:
x=+XVAL+


Any ideas? :)

NOTE: I'm trying to describe the XML replacement for the " character so I used the PHP tag since the CODE tag translates the code to the character in this post.

hqm
03-30-2003, 03:56 AM
Are you doing this in a method or inside of a "onclick" or other event handler attribute? The quoting would be different depending on whether you can use double quotes or not.

If you have a method, then this should work, if I understand the problem

<method name="showstuff">
var XVAL = 12;
debug.write('x="'+XVAL+'"');
</method>




If you're doing something with a snippet of script inside an attribute then you could do


<button onclick="debug.write('x=&amp;quot;'+XVAL+'&amp;quot;')" >quotes</button>


(assuming XVAL is a global)

Grig
03-30-2003, 08:00 AM
cool, thanks!