What I want to be able to do is to:
--- have an "on change" on drop list (containing the table data "titles")
--- this on change runs the javascript function
--- the javascript populates a text area with a "message" column of data in the same table as the corresponding title that is being selected in the drop list.
<li><label for="frm_precan">Canned Response</label>
<span class="input">
<select id="frm_precan" name="precan" onchange="updateText();">
<option value="">--Please Select--</option>
<?php foreach($precan_list as $precan) : ?>
<option value="<?=$precan['id'];?>"><?=$precan['name'];?></option>
<?php endforeach; ?>
</select>
</span>
</li>
</ul>
<textarea style="width: 100%; margin: 0; padding: 0; border-width: 1; font-family: courier;" name="message" rows="10" id="text_area"></textarea>
<script type="text/javascript">
function updateText()
{
var value = $("#frm_precan option:selected").text();
$('#text_area').val(value);;
}
</script>
This is the code, and it currently can put the selected title in the text area. However, I need to get data from database according to selected index of the dropdown and fill the textbox with it. How can I do this?