List Boxes


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: List Boxes

  1. #1
    Nate Guest

    List Boxes


    I need to be able to move (or copy) data from one list box to another when
    a button is clicked.

    I am having a problem with the recognition of the Options object. Here is
    the code below:

    <script>

    function fromPartiesToPlaintiff()
    {

    var index = document.frmRelatedParties.selParties.selectedIndex;
    var text = document.frmRelatedParties.selParties.options[index].text;
    var value = document.frmRelatedParties.selParties.options[index].value;
    var len = document.frmRelatedParties.selPlaintiff.length;

    var new_element= document.createElement("option");
    new_element.text = text;
    new_element.value = value;
    new_element.selected=true;
    document.frmRelatedParties.selPlaintiff.options[len]=new_element;

    }

    </script>

    <form name=frmPlaintiff>
    <input type=button name=addPlaintiff value="Add Plaintiff --->>>" onClick="fromPartiesToPlaintiff()">
    </form>

    I get an error in the function when this line is reached:
    document.frmRelatedParties.selPlaintiff.options[len]=new_element;

    Any ideas????

    TIA
    Nate

  2. #2
    Michael Guest

    Re: List Boxes


    Nate,
    you get the selected option from the list as,

    document.frmRelatedParties.selParties.options[document.frmRelatedParties.selParties.selectedIndex].value

    Let me know if you have any questions,
    Michael

    "Nate" <nkane@enak.com> wrote:
    >
    >I need to be able to move (or copy) data from one list box to another when
    >a button is clicked.
    >
    >I am having a problem with the recognition of the Options object. Here is
    >the code below:
    >
    ><script>
    >
    >function fromPartiesToPlaintiff()
    >{
    >
    >var index = document.frmRelatedParties.selParties.selectedIndex;
    >var text = document.frmRelatedParties.selParties.options[index].text;
    >var value = document.frmRelatedParties.selParties.options[index].value;
    >var len = document.frmRelatedParties.selPlaintiff.length;
    >
    > var new_element= document.createElement("option");
    > new_element.text = text;
    > new_element.value = value;
    > new_element.selected=true;
    > document.frmRelatedParties.selPlaintiff.options[len]=new_element;
    >
    >}
    >
    ></script>
    >
    ><form name=frmPlaintiff>
    ><input type=button name=addPlaintiff value="Add Plaintiff --->>>" onClick="fromPartiesToPlaintiff()">
    ></form>
    >
    >I get an error in the function when this line is reached:
    >document.frmRelatedParties.selPlaintiff.options[len]=new_element;
    >
    >Any ideas????
    >
    >TIA
    >Nate



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center