Jump to content


Photo

Problem with passing multiple selection list values to another one


  • Please log in to reply
1 reply to this topic

#1 nezbie

nezbie
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts
  • LocationFINLAND

Posted 13 June 2006 - 09:04 PM

<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>

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?
:: Be patient with me, I\'m new to PHP and MySQL :: :)

#2 nezbie

nezbie
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts
  • LocationFINLAND

Posted 13 June 2006 - 09:28 PM

document.notifications_form.elements['lopullinen[]'] solved the problem.
:: Be patient with me, I\'m new to PHP and MySQL :: :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users