0
<select name='brgylist' id='list'>
                    <?php
                    require_once "connection.php";
                    $result = mysql_query("SELECT `BrgyCode`,`Barangay` FROM `ref Barangay`");
                    while($rec = mysql_fetch_array($result))
                    {
                        echo '<option value="'.$rec['BrgyCode'].'">'.$rec['Barangay'].'</option>';

                    }
                    echo 'The Code selected is '.$rec['BrgyCode'];
                    ?>

                    </select>

I want to store the selected dropdown list to a variable because i will use it to query to output in different dropdownlist. please i need your help on this.

Edited by melhanz

3
Contributors
2
Replies
13
Views
3 Years
Discussion Span
Last Post by minitauros
0

Use the "selected" key word as

<select name='brgylist' id='list'>
<?php
require_once "connection.php";
$result = mysql_query("SELECT `BrgyCode`,`Barangay` FROM `ref Barangay`");
while($rec = mysql_fetch_array($result))
{
echo '<option value="'.$rec['BrgyCode'].'" selected="selected">'.$rec['Barangay'].'</option>';
}

?>
</select>
0

Are you asking how you can use the item that the user selects in your <select> to fill another <select> element?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.