hi all,
im pretty sure i got this code from here originally but it was to long ago now
basically i have a javascript function that converts html 2 php for me.the trouble is i want it to use single quotes instead of double quotes.
ill give you an example, if input the following html into my form,
It outputs as follows.Code:<a href="somelink.html">Click Here</a>
which is fine and works perfect except i want it to output like so;PHP Code:<?php
echo "<a href=\"somelink.html\">Click Here</a>\n";
?>
here is the javascript;PHP Code:<?php
echo '<a href="somelink.html">Click Here</a>'."\n";
?>
Code:<script type="text/javascript" language="javascript"> function brCheck(data) { var ns4 = document.layers; var ns6 = document.getElementById && !document.all; var ie4 = document.all; if(ns4) br = "%0A"; else if(ns6) br = "%0A"; else if(ie4) br = "%0D%0A"; else br = "%0D%0A"; data.value=data.value.replace(/"/gi,'\\"'); dataArr=escape(data.value).split(br); data.value=""; } function scriptPHP(data){ brCheck(data); for (i=0; i<dataArr.length; i++){ data.value+= (i==0) ? "<?php\necho " : "echo " data.value+= "\"" + unescape(dataArr[i]); data.value+= (i!=dataArr.length-1) ? "\\n\"; \n" : "\\n\";\n" } data.value+="\?>" } </script>
i think it might fairly easy im just to dumb lol, any help would greatly appreciated.




Reply With Quote


Bookmarks