"Gram" <gr******@hotmail.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.getElementById("selectId").options;
var textRef = document.getElementById("textareaId");
var words = [];
for (var i=0;i<optsRef.length;i++) {
if (optsRef[i].selected) {
words.push(optsRef[i].text);
}
}
textRef.value = words.join(" ");
}
</script>
<select id="selectId" multiple="multiple">
<option>Some</option>
<option>Words</option>
<option>To</option>
<option>Select</option>
<option>From</option>
</select>
<input type="button" value="Transfer Words" onclick="transferWords()">
<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.'