Jump to content


This topic is now archived and is closed to further replies.


list box, mutliple selection

Recommended Posts

<td valign='top'>
    <select name="copy1" multiple size='10'>
        echo $list_countries = "SELECT * FROM languages_main ORDER BY id";
        $query_list_countries = mysql_query($list_countries);
        $num_rows = mysql_num_rows($query_list_countries);
        while($row = mysql_fetch_array($query_list_countries))
                $id = $row['id'];
                $country_name = $row['lang_name'];
                echo "<option value='$id'>$country_name</option>";
<td valign='middle' align='center'>
    <input type="button" name="right" value="&gt;&gt;" onClick="copySelectedOptions(document.forms[0]['copy1'],document.forms[0]['copy2'],false);return false;"><BR><BR>
    <input type="button" name="right" value="&lt;&lt;" onClick="removeSelectedOptions(document.forms[0]['copy2']); return false;"><BR><BR>
    <select name="copy2" multiple size=10></select><br />
    <td><input type='submit' name='submit' value='Submit'></td>

copy1 has 20 countries listed in it(static), copy2 will the be the second list box which will be filled when a user select a country from copy1, my question is how can I get all the selected item from copy2 in order to insert it into my table?

Share this post

Link to post
Share on other sites
php is a server side script so copy2 will not populate unless you submit your selection to be parsed to the server. in another words you will have to have one list box with the countries in it with a submit button. Once they select the country they hit the submit button the page will reload and the second list box will populate with what you want.

Hope that helps


Share this post

Link to post
Share on other sites


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.