"Gram" <gr******@hotma il.com> writes:
Hello,
Can anyone help me with the following, or point me to a site that can help:
I have a list of words in a List and I want a user to be able to select
several words from this list, hit a button and these words appear in a
textarea.
I assume your "List" is a select element.
Code:
---
<script type="text/javascript">
function transferWords() {
var optsRef = document.getEle mentById("selec tId").options;
var textRef = document.getEle mentById("texta reaId");
var words = [];
for (var i=0;i<optsRef.l ength;i++) {
if (optsRef[i].selected) {
words.push(opts Ref[i].text);
}
}
textRef.value = words.join(" ");
}
</script>
<select id="selectId" multiple="multi ple">
<option>Some</option>
<option>Words </option>
<option>To</option>
<option>Selec t</option>
<option>From</option>
</select>
<input type="button" value="Transfer Words" onclick="transf erWords()">
<textarea id="textareaId" >Words appear here</textarea>
---
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'