Jump to content

Problem with passing multiple selection list values to another one


Recommended Posts

[code]<script language="javascript">
  function doCopy(list1, list2) {
    
    for (var i=0; i< list1.length; i++) {
      
      if (list1.options[i].selected == true) {
        
        var cancopy = true;
        
        for (var j=0; j< list2.length; j++) {
          
          if (list1.options[i].value == list2.options[j].value) {
            
            cancopy = false; break;
        
          }
          
        }
        
        if (cancopy == true) {
          
          list2.options[list2.options.length] = new Option(list1.options[i].text, list1.options[i].value, false, true); }
      
      }
      
    }
    
  }
</script>

<form name="notifications_form">

<select multiple size=5 name="jakelulista" style="width: 150px;">
  <option value="1">1
  <option value="2">2
  <option value="3">3
</select>

<input type="button" value="Siirrä arvo" onClick="doCopy(document.notifications_form.jakelulista,document.notifications_form.lopullinen);" />

<select multiple size=5 name="lopullinen" class="inputFields" style="width: 150px;"></select>

</form>[/code]

Ok, the code is above. It works fine. But, I'd need to pass multiple values in this selection list via the form. Now, when the name is just "lopullinen" it passes the last value in this list. I've tried different things to change this lists name in an array type name, like "lopullinen[]" when it can pass multiple values via the form, but the script stops working.

Can someone help me with this, please?
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.