I think i see where you are going with this.
However, since php runs on the sever side and not client side, you will not be able to automatically fill that value into the input field unless you "post" to that page.
for example:
here would be a file that posts a select to its on page, then auto fills the input box with the selected data:
this.php file:
<form action = this.php>
<select name = "myselect">
<option value =1>Select me</option>
</select>
</form>
<?
$selected = $_POST[myselect]
echo "<input type=\"text\" name=\"textfield\" value = $selected>";
?>
So, the html form up there would take your selected data, post it to the this.php file where you can assign the value in the php section. Then you echo out your input field with the $selected variable as your value.
Now, if you are using a database to pull information, then again you would have all that data stored into variables...so you could always use that data in your "echo" statements.
Again, however, you can not take action with a php script unless the whole page is refreshed or "posted" to from a form within itself.
Do you see what I mean?
Now, what you could do is use php to get whatever information you want out of your database.....I assume that you would want to pull all of your options out of a database? Then use javascript to auto-populate your input field......
Here would be that option:
First, we need to put the javascript function:
<SCRIPT LANGUAGE="javascript">
function copy()
{
document.myform.mytext.value = document.myform.myselect.value;
}
</SCRIPT>
Next, print out a beginning select tag
<select name = myselect>
Now do php to get all options
<?
//database connection
$dbh=mysql_connect ($servername,
$dbusername, $dbpassword);
//query
$query = "SELECT * FROM table where whatever = '$whatever'";
//putting results into result array
$result = mysql_db_query ($dbname,$query);
//error checking
if($result == false){
echo mysql_errno().":".mysql_error()."<BR>";
exit;
}
//get the number of rows returned
$numofRows = mySQL_num_rows($result);
//loop through and create your options:
for ($i = 0; $i > $numofRows; $i++){
$variable = mysql_result($result, $i, "selects_field");
echo "<option value =$variable>$variable</option>";
}
?>
now end select
</select>
put input box.
<input type="text" name="mytext">
</form>
So the php will take care of getting all the data from the database, create your options in your select, then the javascript function will autopopulate your input form....
I covered a lot of stuff there..., and you may only use certain parts for your application. Let mek now if you need more explaining on any part of it....