-2

这是代码

<form class="navbar-search pull-right header-link" method="post" name="searchportlet" id="searchportlet" onsubmit="window.location.href='/s.nl?ext=F&amp;sc=22&amp;category=&amp;search='+escape(document.forms['searchportlet'].elements['search'].value);return false;">
    <div class="dowith clearfix">
        <a href="#" class="left" onclick="window.location.href='/s.nl?ext=F&sc=22&category=&search='+escape(document.forms['searchportlet'].elements['search'].value);return false; return false;">
            <img alt="" src="/images/search.png" style="margin-top: 5px;">
        </a>
        <input name="search" type="text" onsubmit="window.location.href='/s.nl?ext=F&sc=22&category=&search='+escape(document.forms['searchportlet'].elements['search'].value);return false; return false;" onfocus="if (this.value == 'Search entire store...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search entire store...';}" value="Search entire store..." class="right textfield" id="search_input">
    </div><!--End dowith-->
</form>

如何保留用户输入的搜索输入文本。我需要 js 或 jquery 中的解决方案。表单提交后搜索整个商店值必须替换为用户输入的文本

4

1 回答 1

0

Looking at your site, there is this section which gets executed after your page has been loaded:

jQuery(document).ready(function($) {

add something like this below it:

$('#search_input').val(location.href.split('&search=')[1] || '');

This is not a good solution (basically reads the URL and picks search term if exists). If you can edit server-side code, better handle it there.

于 2013-11-07T16:44:55.477 回答