Hi all,
Ive been coding my forums and im trying to make a 'preview' button, thing is I have coded a markup language with regular expressions and that converts <> to < and > , to stop html tags.
its called parse_text($string);
I have got this to work:
function preview_data ($field) {
?>
<script language="JavaScript">
function previewDATA(form) {
var open_width = parseInt((screen.availWidth - 370) / 2);
var open_height = parseInt((screen.availHeight - 225) / 2);
var data = form.<? echo "$field" ?>.value;
var OpenWindow = window.open("","preview_popup","top=" + open_height + ",left=" + open_width + ",toolbar=no,scrollbars=yes,status=no,height=250,width=425");
OpenWindow.document.write("");
OpenWindow.document.write("<title>ScriptaZ.com - Preview ...</title>");
OpenWindow.document.write(data);
OpenWindow.document.write("<br><br><br><hr size='1' width='100%'><form><center><input type='button' value='Close This' onClick='window.close();'></center></form><br>");
OpenWindow.document.write("");
}
</script>
<?
}
What im trying to do, is get the JavaScript variable 'data' to be parse_text();'d and then nl2br();'d
But no luck, I tried this:
function preview_data1 ($field) {
?>
<script language="JavaScript">
function previewDATA(form) {
var open_width = parseInt((screen.availWidth - 370) / 2);
var open_height = parseInt((screen.availHeight - 225) / 2);
var unparsed_data = form.<? echo $field ?>.value;
var parsed_data = <? parse_text(?>unparsed_data<?); ?>;
var data = <? nl2br(?>parsed_data<?); ?>;
var OpenWindow = window.open("","preview_popup","top=" + open_height + ",left=" + open_width + ",toolbar=no,scrollbars=yes,status=no,height=250,width=425");
OpenWindow.document.write("");
OpenWindow.document.write("<title>ScriptaZ.com - Preview ...</title>");
OpenWindow.document.write(data);
OpenWindow.document.write("<br><br><br><hr size='1' width='100%'><form><center><input type='button' value='Close This' onClick='window.close();'></center></form><br>");
OpenWindow.document.write("");
}
</script>
<?
}
Any ideas?