Hi all,
I have a form named frm_test. When the user selects from the SELECT menu the Javascript is called to submit the form.
The PHP performs a Database query and populates a textarea.
All above works fine so far.
However, If I add another SELECT menu and add the same functionality to that my problem occurs...
When the user selects from the 2nd menu the data contained in the textarea from the First SELECT menu is lost.
How can I prevent the Text area losing its data??
Thanks.
<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();">
<option value="0">Select Investment Type</option>
<?php
echo $option;
?>
</select>
</p>
<p>
<label for="inv_type_note">Note</label>
<textarea cols="60" rows="8" name="inv_type_note" id="inv_type_note"><?php if(isset($inv_note)){echo $inv_note;} else {echo $inv_note;} ?>
</textarea>
</p>
Javascript:
<script language="Javascript">
function change()
{
document.getElementById("frm_test").submit();
}
</script>
Processing Code
$id = $_POST['investment_type'];
$price_id = $_POST['price_list'];
//echo '<p>ID: '.$id.'</p>';
if(isset($id) && $id !="0")
{
// Get Investment Types
$query = "SELECT inv_note ".
"FROM investment_type ".
"WHERE investment_type_ID = '$id'";
//echo $query;
$result = mssql_query($query) or die('Select Error');
while($row = mssql_fetch_array($result))
{
$inv_note = trim($row['inv_note']);
}
} // end isset