【问题标题】:Form search submission help表单搜索提交帮助
【发布时间】:2011-01-30 17:56:19
【问题描述】:

大家好,我有一个表单,用户可以点击 4 个按钮来提交。一个搜索所有内容,另一个搜索用户,另一个搜索剪辑,第四个搜索主题。现在我的问题是按钮的名称=类别和值=(搜索类型),我打算将用户发送到地址栏中的类别=值的搜索结果页面(使用 GET 方法)。这在 Firefox 上运行良好,但在使用 google chrome 时根本无法运行。有什么帮助吗?代码如下:

<form method="get" action="search.php" name="search" onsubmit="return Validate();">
        <input type="text" class="searchit" title="Search..." name="search" id="search" /><br/>

        <label><span> </span> <input name="submitter" type="submit" value="Search" class="searchsubmitButton" id="submitter" /></label>
        <span class="searchfor">Search for:</span>
        <label><span> </span> <input name="c" type="submit" value="Users" class="searchsubmitButton" id="submitter" /></label>
        <label><span> </span> <input name="c" type="submit" value="Clips" class="searchsubmitButton" id="submitter" /></label>
        <label><span> </span> <input name="c" type="submit" value="Topics" class="searchsubmitButton" id="submitter" /></label>
    </form>

【问题讨论】:

  • 您所说的“在 google chrome 中不可用”是什么意思?您是否收到错误消息?不想要的输出?给我们更多信息,我们将能够更好地帮助您。 :D
  • 它不起作用,因为在地址栏中我没有得到 c=users 或 c=clips 或 c=topics,只是搜索=(搜索查询)。
  • 正如我在下面建议的,将 字段放在 标签之外。

标签: html forms


【解决方案1】:

因为您的输入字段在&lt;label&gt;&lt;/label&gt; 标签内?

【讨论】:

    【解决方案2】:

    看看这个帖子:Safari and Chrome back button changes hidden and submit values in forms

    我能想到的最简单的解决方案是为您创建一个名为“c”的隐藏字段。然后,当点击提交按钮时,在提交表单之前先在“c”隐藏字段中设置值(用户、剪辑或主题)。

    【讨论】:

    • :D...好吧,我今天要破解了...我修复了链接。 :)