I have a one combo box which display values from a table. But onchange i want the selected value in other text box.
[PHP]<?
echo "<select name='selectpg'>\n";
echo "<option value='Select Group' selected>Select Group</option>";
$query = "SELECT t.gname FROM group AS t ORDER BY t.gname ASC";
$res = @mysql_query($query);
while($row = mysql_fetch_array($res))
{
printf("<option value=\"$row[gname]\">$row[gname]</option>\n");
}
echo "</select>";
?>[/PHP]
Any body have idea about this, plz let me know
Thanks & Regards,
Praveen
Hi Praveen,
I would do this with a simple javascript function called by the Select onchange event.
[html]
<select id="selectpg" onchcnage="poplateText('selectpg', 'textDisplay');"
[/html]
NOTE: 'textDisplay' is the ID of the input text you control where the value should display. the rest of your code should be fine, this is just to illustrate where the onchange call goes.
The javascript would look like:
[code]
function populateText(pcSourceID, pcTargetID)
{
// get the source value
lcSourceValue = document.getElementById(pcSourceID).value ;
//set the target value
document.getElementById(pcTargetID).value = lcSourceValue ;
}
This simple function should do the trick.
Cheers
nathj