PDA

View Full Version : Newbie: Writing to a window


FireCracker
06-16-2005, 04:18 PM
Hello everyone, I am new here, but this seems like a rather good, active forum. I"m battling with some JavaScript, a language that I've had very limited use of until recently. I'm atempting to build an HTML editor that is based in PHP; however, I am currently working on the "Preview HTML" function which will open a new window, and write the HTML from the textarea in the form to that new window. I'm following an example off of the HTML Goodies website.

As of right now I can get the window to open; however, I am unable to get the code to write to the textarea. I'm pretty sure that there is some common n00b mistake in it, and a little bit of help would be great.

Here is my current code:

<head>
<script language="JavaScript">
//The function to create the window in the head
function openPreview()
{
var OpenWindow=window.open("", "newwin");
OpenWindow.document.write(document.htmledit.flie_conts.value);
}
</script>
</head>

<form name="htmledit" method="post" action="savefile.php">
<input type="hidden" name="file_name" value="index.html">
<textarea rows="10" cols="60" wrap="off" name="file_conts"><? echo $file; ?></textarea><br>
<input type="submit" name="submit" value="Save File"><input type="button" name="Preview" value="Priview HTML" onClick="openPreview()">
</form>


The error that I am recieving from IE is as follows:

document.htmledit.flie_conts.value is null or not an object


Thank you all very much for your help

nikkiH
06-16-2005, 06:40 PM
I hope you're doing this as a learning exercise. FCKEdit already does this and more. (if you are just playing to learn, go check out their source, as they are GNU license, and you can pick up some neat tricks)

That said, you seem to have a typo, since you don't have an element named flie_conts. It's named file_conts. :D

FireCracker
06-21-2005, 04:44 PM
Thank you, that little typo was causing all that trouble.

I'm not exactly doing this for just practice, I'm creating a resume site, so I am making everything from scratch, just to prove that I can do it.

Thanks again for the help.