DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
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



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links