I read other people's post regarding this subject and I am still confused.
I have a form that has a select box thats created from php parsing the mysql database. I also have a textarea box below it. I want to design it so that when a user clicks on the select box, the second textbox is automatically filled. I know I need to use javascript, but have no idea how. I need to somehow transfer the array from php to javascript.
I made this page to show an example.
http://www.spguild.com/eqpointsys/a_test.php
and the code
this gets the data
$sql = "SELECT * FROM items";
$result = $obj->Query($sql);
$num = &$obj->Numrows($result);
for ($i=0;$i<$num;$i++)
{
$item_name[] = mysql_result($result,$i,"item_name");
$item_stats[] = mysql_result($result,$i,"stats");
}
this is the form
<FORM NAME="itemdata">
<P>
Select an item<BR>
<SELECT NAME="item_name" onChange="getData(this.form)">
<OPTION>Choose Item
<? for ($i=0;$i<$num;$i++)
{
echo "<OPTION>";
echo $item_name[$i];
}
?>
</SELECT>
</P><P>
<font color="#FF0000">EDIT</font> Item Stats
<BR>
<textarea name="stats" rows="10" cols="35">
</textarea>
<BR>
</FORM>