Hi all,
I've got a dropdownbox and a textbox. The dropdownbox is related to a MySQL database.
When i click on an item in the dropdownbox the same value is viewed in the textbox. But it have to show a value from another column in the database...
Here is the code
Selectitem.php
<?
include ("db.php");
function select_item_price()
{
$qy = "SELECT debiteur,deb_naam FROM uren_deb";
$rs = mysql_query($qy);
while ($r= mysql_fetch_array($rs,MYSQL_NUM))
{
$select .= "<option value='{$r[0]}'>{$r[0]}</option\n>";
$prices[] = $r{1};
}
return array ($select, $prices);
}
?>
Index.php
<?
include("db.php");
include("selectitem.php");
?>
<HTML>
<HEAD>
<? list ($select, $prices) = select_item_price (); ?>
<script>
function showPrice(selecteditem)
{
document.form1.price.value = selecteditem.value;
}
</script>
</HEAD>
<BODY>
<form name= "form1">
<select name="item" onClick="showPrice(this)">
<? echo $select; ?>
</select>
<input type="text" name="price" value= "">
</form>
So the question is how do i get the other value from the other column in the textbox when i select something in the dropdownbox
Ill hope it clear to understand 😉
Thanks Clee2004