【问题标题】:On form submit link to a url including the input value在表单上提交包含输入值的 url 链接
【发布时间】:2015-01-11 11:49:06
【问题描述】:

我想直接链接到一个 url,例如 index/link/product-name,其中 value 是表单上输入的值。我不希望它转到 index/link.php?product-name=value。有没有办法做到这一点?

    <form id="search" class="header_form" action="">
        <input id="product-name" class="header_search" type="text" placeholder="What are you looking for?" required>
        <span>
        <input type="button" value="Search">
        </span>
    </form>

【问题讨论】:

  • 它与 jquery , html 无关 :) 你需要 php , htaccess 配置。 jQuery 也有一些限制,否则我们永远不需要 php。

标签: html .htaccess mod-rewrite


【解决方案1】:

每次您输入时,文本字段中的内容都会更新表单的操作:

$("#product-name").keyup(function(){
$("#search").attr('action',"index/link/"+$(this).val());

});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-24
    • 1970-01-01
    • 2012-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-01
    相关资源
    最近更新 更多