Click to See Complete Forum and Search --> : duplacate text area


aiden857181
04-23-2007, 04:53 PM
:( Please Help. ok what I have is a page on my web site with one large text area that customers can fill in. but i need that when they click a button and the text area not the text will duplacate on the page so they can fill in new info.
Please Please HELP as i need this up and running by tomrrow.


Regards
Aiden.

aiden857181
04-23-2007, 04:59 PM
Please Help. ok what I have is a page on my web site with one large text area that customers can fill in. but i need that when they click a button and the text area not the text will duplacate on the page so they can fill in new info.
Please Please HELP as i need this up and running by tomrrow.


Regards
Aiden.

sftrprod
04-23-2007, 05:05 PM
"form" is the name of the form and "textarea" is the name of the textarea.
You will need also to put <div id="duplarea"></div> wherever you want to the duplicate to appear.

function duplicate(form, textarea) {
duphtml="<textarea>"+document.forms[form].elements[textarea].value+"</textarea>";
document.getElementById('duplarea').innerHTML=duphtml;
}

I think that should work.

mateobus
04-23-2007, 05:11 PM
you can use javascript to do that, just have a button with the onclick property to run a function that adds a text area to a div...
something like this.

//add this to the head

<script type="text/javascript">
function addTextArea(){
document.getElementById('divID').innerHTML = '<textarea>blah</textarea>';
}
</script>

//add this to the html

<div id="divID">
</div>
<input type="submit" onclick="addTextArea()" />

anyways, something like this, you get the picture

aiden857181
04-23-2007, 05:30 PM
But how do i determin the text area size.

mateobus
04-23-2007, 05:34 PM
just change the function to print the size you want:

document.getElementById('divID').innerHTML = '<textarea rows="12" cols="10">blah</textarea>';

aiden857181
04-23-2007, 05:44 PM
You saved my ass.

aiden857181
04-23-2007, 06:01 PM
how do i name the area to include in a form.

mateobus
04-23-2007, 08:41 PM
its simple html:

function addTextArea(){
document.getElementById('divID').innerHTML = '<form action="nextpage.html" method="post"><textarea>blah</textarea></form>';
}

konithomimo
04-23-2007, 09:11 PM
"form" is the name of the form and "textarea" is the name of the textarea.
You will need also to put <div id="duplarea"></div> wherever you want to the duplicate to appear.

function duplicate(form, textarea) {
duphtml="<textarea>"+document.forms[form].elements[textarea].value+"</textarea>";
document.getElementById('duplarea').innerHTML=duphtml;
}

I think that should work.
That will work create a new textarea and insert the old text from the first textarea. What that OP needs is to use DOM with createElement to create a new textarea. Or, one could use cloneNode() to make a clone of the original textarea, which is sometimes useful because it will have the same name and attributes. innerHTML will work, but is non-DOM, and thus not recommended.