Hi there,
I'm trying to use a dynamic drop down box to populate some input fields.. So far I can make the drop down box populate correctly. I can also link the input fields to an id in my table, however I'm not sure how to link that id with the id of the item chosen from the drop down box.
Basically, I want my users to be able to make a selection from the drop down box and have it fill in "type" and "shortrange" from the table. This is part of a larger form that is all submitted to another table at the end...
Here is what I have so far:
<?php
//this is my include to connect to the db.
include("glob.php");
$query="SELECT * FROM equipment";
$result = mysql_query ($query);
echo "<select name='weapon1'>";
echo "<option value='none'>---Select---</option>";
//this part dynamically fills in the dropdown
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value='weapon1'>$nt[name]</option>";
}
echo "</select>";
//this was my attempt at at least filling the input boxes with something, it'd be nice if we could just replace the 3 with something lol
$query2="SELECT * FROM equipment WHERE id = 3";
$result2 = mysql_query ($query2);
while($row = mysql_fetch_array($result2))
{
$type=$row['type'];
$shortrange=$row['shortrange'];
echo "<input type ='text' name = 'type' value = $type>";
echo "<input type ='text' name = 'shortrange' value = $shortrange>";
}
?>
I plugged in id = 3, just to see what it'd look like, but I realize that won't work, I don't know java, but I might need that to keep the page from refreshing and wiping the information from the rest of the form, right? Any help is appreciated!