View Full Version : someone please help

09-22-2005, 09:41 PM
How do I copy multiple selects to a textarea?

I'd like a button that adds/removes selections to/from the textarea

Please help. It's for a PHP mailing list editor.

I know very little about javascripting


09-22-2005, 09:52 PM
There are excelent javascript manuals on Internet, use google to find them

09-22-2005, 10:13 PM
this should get you started on right track! :rolleyes:

<script type="text/javascript">
function copySelects(from, to) {
var options = new Array;
var select = document.getElementById(from);
var textarea = document.getElementById(to);
for (var i = 0; i < select.options.length; i++) {
var option = select.options[i];
if (option.selected) {
options[options.length] = (option.value || option.innerHTML);
textarea.value = options.join("; ");
<select id="emails" size="10" multiple="true">
<button onclick="copySelects('emails','email-textarea');">Copy</button>
<textarea id="email-textarea" rows="10" cols="60"></textarea>

09-22-2005, 10:32 PM
Thanks KC-Luck!!!

That definitely helps!!

I'm pulling addresses from mailing lists in PHP and I had textarea to textarea working, but this was trickier.

Now all I have to do is send a <br> instead of a ; and figure out how to remove selections from the textarea.