473,327 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Copy from a list to a textarea

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.

Thanks in advance for your help.

Gram.
Jul 20 '05 #1
3 6226
"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.'
Jul 20 '05 #2
"Gram" <gr******@hotmail.com> wrote in message news:<FY****************@news.indigo.ie>...
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.

Thanks in advance for your help.

Gram.


Gram,

Check the attached code, I think is what you're looking for.

Wagner

-----
<html>
<head>
<script language=JavaScript>
function copy(){
var o, i;
with(document.myform){
myarea.value = '';
for (i=0; i < mylist.options.length; i++){
o = mylist.options[i];
if (o.selected){
if (myarea.value != '')
myarea.value += '\n';
myarea.value += o.text;
}
}
}
}
</script>
</head>
<body>
<form name=myform>
<select name=mylist multiple>
<option>Text 1
<option>Text 2
<option>Text 3
<option>Text 4
<option>Text 5
<option>Text 6
</select>
<br><br>
<input type=button name=mybtn value="Copy" onclick="copy();">
<br><br>
<textarea name=myarea rows=20>
</textarea>
</form>
</body>
</html>
Jul 20 '05 #3
Wagner

Thats it, Thank you!

Gram.
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mike | last post by:
I have a form that has a place for "Customer" and "CO-Customer" information. I want to put a button by the CO-Customer section that will copy the Address information from the Customer. Do I...
3
by: cv | last post by:
Hi all, I have to copy two set of data from 2 files(notepad/excel) say, products and their corresponding prices to list/textarea/table. I should be able to retrieve the product and corresponding...
4
by: just1coder | last post by:
Is it possible to create a dropdown list populated by the contents of a textarea? <textarea> <a name="this">this</a> <a name="that">that</a> </textarea> Then, the dropdown would have the <a>...
5
by: Gernot Frisch | last post by:
How can I put text from a <textarea name="test"></textarea> into my clipboard (Windows, Firefox+IE). -- -Gernot int main(int argc, char** argv) {printf ("%silto%c%cf%cgl%ssic%ccom%c", "ma",...
4
by: devine | last post by:
Hi All, I am VERY new to Javascript. I have been provided with some code, which will enable me to hide/show a text area and change a submit button dependant on a check box. <!DOCTYPE html...
9
by: Ajinkya | last post by:
Hello friends ! , I am very new to java script.If anyone can help me then I will be very very thankful to his/her. I am using php and mysql in my project and I have one textarea and one...
0
by: saijin | last post by:
I'm planning to call a list of data from an XML file but when I duplicate the content inside the <data></data> it is not showing anything Here's the ActionScript 3.0 import...
0
by: saijin | last post by:
Are there anyway that I can add a checkbox on a component that supports "dataProvider" and HTML tags? Here's what I have so far: import fl.data.DataProvider; import fl.managers.StyleManager;...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.