Click to See Complete Forum and Search --> : Sending to a textarea


netman182
03-20-2003, 12:10 PM
I want to send text from a form to a textarea. i've tryed for a few days to get it but can't can anyone help. i'm makeing a css generator for school and i want to send this:

document.write("BODY {<BR>BACKGROUND COLOR: "+ frmCSS.bgcol.value +"; <BR> BACKGROUND-IMAGE: "+ frmCSS.bgimg.value +";<BR> BACKGROUND-ATTACHMENT: fixed; <BR> COLOR: "+ frmCSS.txtcolor.value +";<BR> FONT-WEIGHT: "+ frmCSS.txtweight.value +";<BR>FONT-STYLE: "+ frmCSS.txtstyle.value +";<BR> FONT-FAMILY: "+ frmCSS.txtfont.value +"; <BR> TEXT-ALIGN: "+ frmCSS.txtalign.value +" } <BR><BR>H1 {<BR>COLOR: "+ frmCSS.h1color.value +"; <BR> FONT-WEIGHT: "+ frmCSS.h1weight.value +";<BR>FONT-STYLE: "+ frmCSS.h1style.value +";<BR> FONT-FAMILY: "+ frmCSS.h1font.value +"; <BR> TEXT-ALIGN: "+ frmCSS.h1align.value +" }<BR><BR>H2 {<BR>COLOR: "+ frmCSS.h2color.value +"; <BR> FONT-WEIGHT: "+ frmCSS.h2weight.value +";<BR>FONT-STYLE: "+ frmCSS.h2style.value +";<BR> FONT-FAMILY: "+ frmCSS.h2font.value +"; <BR> TEXT-ALIGN: "+ frmCSS.h2align.value +" }<BR><BR> A:LINK {<BR> COLOR: "+ frmCSS.ualinkcol.value +";<BR> FONT-FAMILY: "+ frmCSS.ualinkfont.value +"} <BR><BR> A:ACTIVE {<BR> COLOR: "+ frmCSS.alinkcol.value +";<BR> FONT-FAMILY: "+ frmCSS.alinkfont.value +"} <BR><BR> A:VISITED {<BR> COLOR: "+ frmCSS.vlinkcol.value +";<BR> FONT-FAMILY: "+ frmCSS.vlinkfont.value +"}")

Jona
03-20-2003, 12:13 PM
Add document in front of all of the frmCSS.

AdamBrill
03-20-2003, 12:17 PM
Instead of document.write("all the stuff"); do this:

document.formName.textareaName.value="all the stuff";

I think that is what the problem is...

netman182
03-20-2003, 12:23 PM
this still isn't working. i've already tryed both solutions but to no avail....

Jona
03-20-2003, 12:27 PM
<html><head>
<script>
function process(){
document.frmCSS.area.style.backgroundColor=document.frmCSS.bgcol.value;
}
</script><body>
<form name="frmCSS">
<input type=text name="bgcol" value="red"><br>
<input type=button onclick="process()" value="Process"><br><br>
<textarea name="area"></textarea>
</body></html>

netman182
03-20-2003, 12:29 PM
it works thank you. the reason it wasn't doingit was cause it was making anew page. how do i get it not to refresh the page???

Jona
03-20-2003, 01:30 PM
When you use document.write AFTER the page has loaded, it clears the page. It only works right if you use it before the page has loaded. Like this is acceptible:

<script>
document.write("yahoo!!");
</script>

But this is not:

<script>
function foo(){document.write("yahoo!!");}
</script>
<a href="javascript:foo()">Foo!</a>

The second one will clear the pag.