View Full Version : Simplified: How to pass selections to Textarea?

01-28-2005, 05:54 AM
My problem is shown on this (http://blake.prohosting.com/wolfflow/combox.html) page. I have a combo box, and what I need is for the selections the user makes (into List 2) to be written into the textarea below the lists (don't ask why.)

So for example, if the user moves Alaska and Colorado into List 2, those 2 states would be written into the textarea below the lists.

I have a simple function selectAll() attached to the SAVE button which (unsurprisingly) when pressed selects all the items in List 2 .

function selectAll(box) {
for(var i=0; i<box.length; i++) {
box[i].selected = true;
It is called just using this:

<input type="button" name="submit_button" value="SAVE" onClick="selectAll(document.combo_box.list2);">

Also, it doesn't matter to me if the State names are written to the textarea as they are moved between Lists, or if they are moved as a group at the end by the user pressing SAVE.

Can anyone help me with this (pretty please.) How do I get the selected States to be written into the Textarea?


01-28-2005, 11:38 AM
Forgive me if I'm asking silly questions, but why not just iterate through the items at the end of to list which you seem to be doing already several times in function move() and add all the items to the textarea once the sort functions have done that bit for you...?

textareaobj.innerHTML = item[0].text += "<br>" + item[1].text etc...

You only want the items in the from select to be added to the list or sth?

01-28-2005, 03:56 PM
I only want the items in the in the right hand select, List 2, to be added to the textarea.

I added this to function, setTboxValue(), to the buttons' onClick event handler, so it becomes :

onClick="selectAll(document.comboBox.list2); setTboxValue(document.comboBox.list2);"

And the function setTboxValue() is

function setTboxValue(box){

for(var i=0; i<box.length; i++) {
var selectedItem = box[i].selectedIndex;
var selectedItemText = box[i].options[selectedItem].text;


This function was to write the items in List 2 into the textarea, but it doesn't work. Can anybody see what I'm doing wrong with this?
(please help, I'm running out of time!)