Hi all,
I have a html form which contains two select menus and a number of textfields.
When the user chooses from selectmenu1 then selectmenu2 is populated with data pulled from database.
Here is the code for that...
Selectmenu1:
<select name="client" id="client" onchange="change(this.options[selectedIndex].value);">
<option value="0">Select Client</option>
<option value="1">Client 1</option>
</select>
calls this javascript in <head>...
<script language="Javascript">
function change()
{
document.getElementById("funds_frm").submit();
}
</script>
which submits the data to PHP code...
$client = $_POST['client'];
// CHECK IF CLIENT SELECTED
if(isset($client) && $client !="0")
{
$query = "SELECT fund_ID, client_ID, fund_name ".
"FROM fund_name ".
"WHERE client_ID = $client";
$result = mssql_query($query) or die('Select Error');
$options = ''; // SET OPTION VAR
while($row = mssql_fetch_array($result)) // LOOP RESULTS
{
$options .= '<option value="'.$row['fund_ID'].'">'.$row['fund_name'].'</option>';
} // END WHILE
}// END CLIENT CHECK
That works fine.
My problem is doing this repeatedly. When the user selects from selectmenu1 then selectmenu2 is populated.
Then the user selects from selectmenu2 to populate the remaining textfields.
How do I do this without losing previously selected data?
Thanks.