Click to See Complete Forum and Search --> : new window, content based on form


FCB
11-21-2004, 06:28 PM
Hey, I have a button that when clicked opens a window. The window should be the content of the textarea in the form. right now, it doens't do anything, the error is "object doesn't support this property or method" I'm not to good at JS, so I hope somebody can help! Thanks!


<script type="text/javascript" language="javascript">
function preview()
{
review_page = window.open("", "preview", "scrollbars=yes,width=400,height=300")
review_page.document.write("<html><head><title>" + document.forms['mod'].elements['name'].value + "</title></head><body>" + document.forms['mod'].elements['txt'].value + "</body></html>")
}
</script>
<form action="do_mod.php" method="post" name="mod">
Modual Name: (make it descriptive, this is how you will recognize this mod for editing and creating pages)<br />
<input type="text" name="name" size="30"><br />
<input type="hidden" name="type" value="7" /><br />
<textarea name="txt" cols="60" rows="15">Type your HTML code here!</textarea><br />
<br />
<input type="submit" value="Submit" name="submit" />&nbsp;&nbsp;&nbsp;
<input type="button" value="Preview" name="preview" onClick="javascript:preview()" />&nbsp;&nbsp;&nbsp;
<input type="reset" value="Reset" name="reset" />
</form>

Brandoe85
11-21-2004, 07:08 PM
It works for me in IE and Firefox...though I changed this line:

<input type="button" value="Preview" name="preview" onClick="java script:preview()" />

This is all you need to do for that line:

<input type="button" value="Preview" name="prev" onClick="preview();" />

I wouldn't name your button the same name as your function.

FCB
11-21-2004, 07:39 PM
Thanks a lot!