2013-02-22 109 views
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="" /> 

對此有何建議將高度讚賞

+1

你可以添加html和輸入的css你正在改變的值 – Pete 2013-02-22 15:01:15

+0

請找到css和html。您也可以通過在搜索框中輸入來查看http://www.dailybargains.com。 – 2013-02-22 15:22:57

+0

對不起,不需要表單 - 只是輸入和應用於輸入的樣式,但如果你看着你輸入的'blur',你可以看到你正在調用'fill()'並且什麼都沒有傳入你將'#search'的值設置爲你的函數中的任何東西 – Pete 2013-02-22 15:26:59

回答

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;` 
?> 
+0

我按照你的建議提醒。首先它會提醒正確的值,然後提醒未定義 – 2013-02-22 15:26:38