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>
<SCRIPT>
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"
}
</SCRIPT>
<FORM NAME="form1">
<BR><TEXTAREA NAME="testLines" ROWS=8 COLS=55></TEXTAREA>
<P><INPUT TYPE="button" VALUE="Populate the textarea object"
onClick="populate(document.form1.testLines)">
</TEXTAREA>
</FORM>
</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