我在下面有一个搜索表单,它有两个选择输入类型和一个文本输入字段,用户可以按关键字搜索。出于某种原因,每当我点击关键字文本框时,焦点会立即返回到第一个选择框下拉列表中的类别和我,因此我无法在关键字文本框中键入任何内容。谁能明白为什么会这样?
$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> </p>
<p> </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"/>
答案 0 :(得分:0)
我似乎只是通过更改标签来解决问题 标签改为p标签。我想这可以解决冲突。