Hello. I used fwrite before, but I cannot remember how to
write html code with javascript into a file

Example code being:

<body onLoad="document.forms['myForm'].submit()">
<form name = "myForm" action="response.php" method="post">
<input type="hidden" name="id" value="$id">

<SCRIPT LANGUAGE="JavaScript"><!--
How do I write that to a file, because I want the file I write to to be able to function with this code. Why? Because I will always be re-writing it dynamically with a variable based on user input. You see value=$id I want that, if it is 4, to turn into value=4

See what I mean? Including the rest of the code. How can I do this without string errors?