1

由于自动完成,我试图将搜索文本框的值带到下一页。但它只接受在搜索框中输入的值。

我正在使用的代码是:

function fill(thisValue) {
        var abc = $('#search').val(thisValue);
        alert(abc);
        $('#rad').show();
        setTimeout("$('#suggestions').hide();", 200);
        document.getElementById("Form1").submit();
    }

html:

<form action="<?php echo $mainUrl?>/search" method="post" name="Form1" id="Form1" onsubmit="if( ( document.getElementById( 'search' ).value === '' ) || ( document.getElementById( 'search' ).value === 'Search billions of items at the single Platform' ) ){ document.getElementById( 'search' ).focus(); return false;};">
                <input type="text" name="search" placeholder="Search billions of items at the single Platform" id="search" onkeyup="lookup(this.value);" onblur="fill();" autocomplete='off' value="" />
                <input type="submit" name="submit_btn" value="search" class="button" id="button"   />
                <div class="suggestionsBox" id="suggestions" style="display: none;">
                <img src="<?php echo $mainUrl?>/resources/autocomplete/autoComplete/upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
                <div class="suggestionList" id="autoSuggestionsList">


and html

<input type="text" name="search" placeholder="Search billions of items at the single Platform" id="search" onkeyup="lookup(this.value);" onblur="fill();" autocomplete='off' value="" />

对此的任何建议将不胜感激

4

1 回答 1

1

那是因为你在打电话abc

如果你想提醒thisValue,那么你会这样写:

alert(thisValue);

要将值带到下一页,您可以使用:

<form action="search.php" method="POST">
  <input type="text" name="search">`
  <input type="sbubmit" value="search">`
</form>

并在搜索 PHP 中获取搜索值:

<?php
  $searchValue = $_POST["search"];`
  echo $searchValue;`
?>
于 2013-02-22T15:02:26.023 回答