You do this using Javascript and PHP pages.
For simplicity, I create FORMs which for me are simpler to access via javascript.
The page you are displaying to the user has HTML and javascript code like this:
<form name=myform>
<select onchange=gettext(this)>
<option value=1>1</option>
<option value=2>2</option>
</select>
<input type=text name=fillmewithtext value=''>
<form>
<iFRAME name=gettextframe FRAMEBORDER=0 SCROLLING=no src='gettext.php' width='1' height='1' ></iframe>
<script>
function gettext(select.object){
mychoice=this.value;
window.gettextframe.location='gettext.php' ?mychoice='+mychoice;
}
</script>
The javascript above tells the browser to refresh the iframe with a URL that includes the value of the pulldown.
Your file 'gettext.php' looks something like this:
<?
$mychoice=$_GET['mychoice'];
$mytext="You selected choice $mychoice";
echo "
<script>
window.parent.myform.fillmewithtext.value=$mytext;
</script>
";
?>
The javascript above tells the browser to push the returned value $mytext that you have created into the input text field 'fillmewithtext' on the main ('parent') page.
In your case, you would use database queries to create the text in $mytext.
You can easily make this whole affair much more complicated and interesting. I use this method to check proposed usernames and passwords before submtting a new user form, for example. There's lots and lots of cool stuff you can do with this method.