Select List transfer to another List with array

Discussion in 'Javascript' started by richardsith, Apr 20, 2012.

  1. richardsith


    Apr 20, 2012
    Likes Received:
    Hello everyone,
    it's my first post here and I so sorry if I wrong the place.
    My difficulty is view the elements of the first select form to the other one if the first form is set as array.
    The goal is to send the elements of a select form to another one and then record them on a db MySQL, that will show them on a html page.
    I found in this forum the procedure how to create two select form and add 'n remove the items, then with the command .implode of MySQL can join the element and insert multiple items on db and view them on page.
    But if I set the name's select form as array it doesn't work. I've used the following script to have two select form :

    <script language="javascript">
    function getOpt(select1,select2)
    for (bCnt=0;bCnt<select1.length;bCnt++)
    if (select1.options[bCnt].selected)

    function remOpt(select2)
    for (bCnt=0;bCnt<select2.length;bCnt++)
    if (select2.options[bCnt].selected)

    then the select form:

    <table border="0">
    <label for="id">List:<br></label>
    <select name="oneS" id="select_role" size=20 required multiple="multiple"/>
    <option value="101">101</option>
    <option value="102">102</option>
    <option value="103">103</option>
    <option value="104">104</option>
    <option value="105">105</option>
    <option value="106">106</option>
    <input type="button" value="Add"onClick="getOpt(this.form.oneS,this.form.twoS)"><br>
    <input type="button" value="Remove"onClick="remOpt(this.form.twoS)">
    <label for="id">Members List:<br></label>
    <select name="twoS" id="select_role" size=20 multiple="multiple"/>

    if comment the script,the part of buttons, the second form and change the line:
    <select name="oneS" id="select_role" size=20 required multiple="multiple"/>

    <select name="oneS[]" id="select_role" size=20 required multiple="multiple"/>
    I have any issue, can record the items on db and view them on the page, but it's not my goal. Is there some one can help me? please.
    Last edited: Apr 20, 2012
    richardsith, Apr 20, 2012
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.