Forums

This topic is locked

Use Javascript to Populate HTML textarea object

Posted 10 Jul 2007 20:54:06
1
has voted
10 Jul 2007 20:54:06 Austin Clark posted:
I haven't been able to find a solution that works for this, so here goes.

I have a textarea object in which a user can type a project description. What we would really like to add is a series of checkboxes below the textarea that, when clicked, will populate/append the textarea with the relevant additional info.

The only sample I've found that looks like it would remotely work is this:
<pre id=code><font face=courier size=2 id=code>
&lt;SCRIPT&gt;
var newline=null
function populate(textareaObject){
if (navigator.appVersion.lastIndexOf('Win') != -1)
newline="rn"
else newline="n"
textareaObject.value="line 1" + newline + "line 2" + newline
+ "line 3"
}
&lt;/SCRIPT&gt;
&lt;FORM NAME="form1"&gt;
&lt;BR&gt;&lt;TEXTAREA NAME="testLines" ROWS=8 COLS=55&gt;&lt;/TEXTAREA&gt;
&lt;P&gt;&lt;INPUT TYPE="button" VALUE="Populate the textarea object"
onClick="populate(document.form1.testLines)"&gt;
&lt;/TEXTAREA&gt;
&lt;/FORM&gt;
</font id=code></pre id=code>

However, it only works once, and I have no idea how to modify it to have multiple inputs.

I pretty much no nothing about javascript except how to add pre-built scripts to pages and pray that they work.

Any help on this would be most appreciated.

Edited by - LodeRunner on 10 Jul 2007 20:54:57

Reply to this topic