Hi all,
I have a SELECT menu created as below...
<?php
$query = "SELECT investment_type_ID, investment_type, inv_note, inv_note2 ".
"FROM investment_type";
$result = mssql_query($query) or die('Select Error');
while($row = mssql_fetch_array($result))
{
$option .= '<option value="'.$row['investment_type_ID'].'">'.$row['investment_type'].'</option>';
}// end while
?>
<p>
<?php if(isset($error_message['investment_type']))
{ echo $error_message['investment_type'].'<br />'; } ?>
<label for="investment_type">Investment Type</label>
<select name="investment_type" id="investment_type" onchange="change(this.options[selectedIndex].value);">
<option value="0">Select Investment Type</option>
<?php echo $option;
?>
</select>
The Following Javascript is then called...
<script language="Javascript">
function change()
{
document.getElementById("frm_test").submit();
}
</script>
Then the PHP code (positioned at top of page) returns db values...
$investment_type = $_POST['investment_type'];
if(isset($investment_type) && $investment_type !="0")
{
// Get Investment Types
$query = "SELECT inv_note, inv_note2 ".
"FROM investment_type ".
"WHERE investment_type_ID = '$investment_type'";
$result = mssql_query($query) or die('Select Error');
while($row = mssql_fetch_array($result))
{
$inv_note = trim($row['inv_note']);
$inv_note2 = trim($row['inv_note2']);
}
} // end isset
That all works fine. My problem is that once the Select Menu is selected from it does not stay on the selected option.
i.e. the "Select Investment Type" is displayed regardless of what is selected.
How do I ensure the selected option is displayed??
Thanks.
Kevin.