JA4677
JA4677

Reputation: 561

Form field changes focus when I click on the text input

I have a search form below that has two select input types and one text input field where the user can search by keywords. For some reason, whenever I click on keywords text box, the focus changes immediately back to the first select box drop down for Category and I so I can't type anything in the keywords text box. Can anyone see why this is happening?

$categories_list = array();
$ratings_list = array();

try {
$query = $dbh->query("SELECT category, genre, rating FROM posts WHERE 1
GROUP BY category, genre, rating");
$query->setFetchMode(PDO::FETCH_ASSOC);
$iterator = new IteratorIterator($query);
foreach ($iterator as $row) {
    if (empty($row['category']) == false && !in_array($row['category'],
$categories_list))
        $categories_list[] = $row['category'];
    if (empty($row['rating']) == false && !in_array($row['rating'],
$ratings_list))
        $ratings_list[] = $row['rating'];
}
} catch (Exception $e) {
echo '<p>', $e->getMessage(), '</p>';
}
?>


<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>Search Completed Stories</h2>
<form name="search" method="get" 
action="http://example.com/searchB/">
<label>
    Category:
    <select name="category">
        <?php foreach($categories_list as $category) : ?>
            <option><?php echo $category; ?></option>
        <?php endforeach; ?>
    </select>
</label>
<label>
    Rating:
    <select name="rating">
            <option value="">Any</option>
        <?php foreach($ratings_list as $rating) : ?>
            <option><?php echo $rating; ?></option>
        <?php endforeach; ?>
    </select>
</label>
<label>
    Keywords:
    <input type="text" name="keywords">
</label>
<input type="hidden" name="active" value="0">
<input type="submit"/>

Upvotes: 6

Views: 369

Answers (1)

JA4677
JA4677

Reputation: 561

It appears that I solved the problem by simply changing the label tags to p tags instead. I guess that got around the conflict.

Upvotes: 0

Related Questions