murphyz
01-05-2003, 11:27 PM
I have a 'function generate()' script on a page which takes a set amount of html, adds specific text that a user fills in on a form and displays all of this together as html within a text area so that the user can fill out a form, generate the code, copy and paste the information to their site.
That part works fine, but I would like to have a preview button so that the result can be displayed in a new window to ensure it is correct prior to generating the code - is this possible?
An example of what is set up is as follows:
<script>
function generate() {
var code = "welcome to my page - please fill out the form below and copy and paste the code to your site."+document.f.title.value+"<img src=\""+document.f.img.value+"\"> "+document.f.date.value;
code += "<br>"+document.f.name.value+"<br>"+document.f.sub1.value+"<br>"+document.f.sub2.value;
document.f.c.value=code;
}
</script>
<form name="f">
Title - <input type="text" name="title"><br>
Image - <input type="text" name="img"><br>
Name - <input type="text" name="name"><br>
Date - <input type="text" name="date"><br>
Subtext 1 - <input type="text" name="sub1" maxlength="48"><br>
Subtext 2 - <input type="text" name="sub2" maxlength="86"><br>
<input type="button" value="Generate Code!" onclick="generate()"><br><br>
<textarea name="c" rows="8" cols="40">Your generated code will appear here.</textarea>
</form>
I would like an additional button that previews the result in a new window.
Thanks for your help
Mxx
That part works fine, but I would like to have a preview button so that the result can be displayed in a new window to ensure it is correct prior to generating the code - is this possible?
An example of what is set up is as follows:
<script>
function generate() {
var code = "welcome to my page - please fill out the form below and copy and paste the code to your site."+document.f.title.value+"<img src=\""+document.f.img.value+"\"> "+document.f.date.value;
code += "<br>"+document.f.name.value+"<br>"+document.f.sub1.value+"<br>"+document.f.sub2.value;
document.f.c.value=code;
}
</script>
<form name="f">
Title - <input type="text" name="title"><br>
Image - <input type="text" name="img"><br>
Name - <input type="text" name="name"><br>
Date - <input type="text" name="date"><br>
Subtext 1 - <input type="text" name="sub1" maxlength="48"><br>
Subtext 2 - <input type="text" name="sub2" maxlength="86"><br>
<input type="button" value="Generate Code!" onclick="generate()"><br><br>
<textarea name="c" rows="8" cols="40">Your generated code will appear here.</textarea>
</form>
I would like an additional button that previews the result in a new window.
Thanks for your help
Mxx