-
Javascript and php long variable inclusion
1) Script Title: richtext_compressed.js
2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...itor/index.htm
3) Describe problem: I am trying to use the rich text editor with php and mysql.
My situiation is that I can get the text into the mysql table, but when I pull it out, it is then pulled into the php page out the database and stored in a variable (lets call it $html_code.
I then do this to it: $clean_html_code = trim(addslashes($html_code));
which puts the slashes in at the corerct places and removes the excess spaces and gaps.
I then create my ph page, by assigning all the relevant html codeing to a variable called $body and then at tjhe end of the page, I echo $body to display it
NOW - my problem is that because everything is being stored in a variable ($body) when it comes to the javascript I have the following:
$body .= "
<script language='JavaScript' type='text/javascript'>
<!--
//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
writeRichText(\"rte1\", \"".$clean_html_code."\" , 600, 300, true, false);
//-->
</script>";
This works perfectly, providing that the $clean_html_code is shorter than one 'decent length' line of code, because if it runs onto more than one line, the javascript loses it. Javascript seems to be 'line-dependant'.
in an example, the following does not work: (an extract from the source of the html document)
<script language='JavaScript' type='text/javascript'>
<!--
//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
writeRichText("rte1", "<ol><li>fdsf dsf d<span style=\"color: rgb(51, 153, 153);\">fsd fsd fsd<span style=\"background-color: rgb(0, 0, 102);\">sdfsdfsdfsd</span></span></li></ol>
<ul><li>fhdf<span style=\"background-color: rgb(51, 102, 102);\"></span><br></li></ul>" , 600, 300, true, false);
//-->
</script>
however the following displays fine:
<script language='JavaScript' type='text/javascript'>
<!--
//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
writeRichText("rte1", "fdsf dsf d<span style=\"color: rgb(51, 153,153);\">fsd</span>" , 600, 300, true, false);
//-->
</script>
Is there another way of doing this?
Andrew
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks