Jump to content


Photo

list box, mutliple selection


  • Please log in to reply
1 reply to this topic

#1 romio

romio
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 02 June 2006 - 12:15 PM

<td valign='top'>
    <select name="copy1" multiple size='10'>
         <?php 
        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>";
            }
    ?>    
        </select>
</td>
<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>
</td>
<td>
    <select name="copy2" multiple size=10></select><br />
</td>
<tr>
    <td><input type='submit' name='submit' value='Submit'></td>
</tr>

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?

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 02 June 2006 - 01:05 PM

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

Ray




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users