Hello all!
I need some help regarding drop down menus and input boxes. What I am trying to do is allow users to either select options from a drop down menu or enter their own into an input box. As you can see in my code I have both named 'type', for the word type. The only thing is, that any value they enter into the text box must be presented later in the drop down menu. Which is good. Values are taken from the input box just fine. However, if they choose a value from the drop down menu, thereby leaving the input box blank, the type stays blank and the value from the drop down box is not recognized.
I was thinking about naming the input box something like 'type2', however I have to populate the drop down box from any and all values entered into this input box.
I hope that made sense. 🙂 Thanks for any help.
<?
if ($wordssub) {
// process form
$sql = "INSERT INTO words VALUES('$id','$type','$word','$definition','$example','$entrant')";
$results = mysql_query($sql);
echo "Word Added.\n ";
} else{ ?><form name=wordlist method=post action="<?php echo $PHP_SELF?>"><center>
Select a Word Type or Enter a New Type<BR>
<input type="hidden" value="id">
<select name="type" class="sel"><option>Select Type</option>
<?
{
$result = mysql_query("SELECT * FROM words");
if ($myrow = mysql_fetch_array($result)) {
// display list if there are records to display
do {
printf("<option value=\"%s\">%s</option>", $myrow["type"], $myrow["type"]);
} while ($myrow = mysql_fetch_array($result));
}
} ?></select>
<input name="type" type="text" class="ibox"><BR>