I have a javascript to let you see a preview of text entered in a textarea. It opens a new window showning the preview. What I would like to do is have the preview displayed on the same page instead of opening a new window, sort of the way the preview feature works on this forum. Here’s the script I use.
[code=php]
<SCRIPT language=”JavaScript”>
function ShowPreview()
{
var hWndPreviewWindow = window.open(“”,”Preview”,”width=400,height=250,scrollbars=yes,resizable=yes,status=0″);
hWndPreviewWindow.document.open();
hWndPreviewWindow.document.writeln(‘<HTML><HEAD><TITLE>Preview Message</TITLE></HEAD>’);
hWndPreviewWindow.document.writeln(‘<BODY BGCOLOR=”lightyellow”>’);
hWndPreviewWindow.document.writeln(‘<B>This is how your post will look</B>’);
hWndPreviewWindow.document.writeln(‘<A HREF=”javascript:window.close()”>Close Preview</A><BR><BR><BR>’);
var Cont = document.msgform.message.value;
Cont = Cont.replace(/[B]/ig,'<b>’)
Cont = Cont.replace(/[/B]/ig,'</b>’)
Cont = Cont.replace(/[I]/ig,'<i>’)
Cont = Cont.replace(/[/I]/ig,'</i>’)
Cont = Cont.replace(/[U]/ig,'<U>’)
Cont = Cont.replace(/[/U]/ig,'</U>’)
Cont = Cont.replace(/\n/ig,'<br />’)
hWndPreviewWindow.document.writeln(Cont);
hWndPreviewWindow.document.writeln(‘</BODY></HTML>’);
hWndPreviewWindow.document.close();
}
</SCRIPT>