How to pass the value of an option field as well as an input box via post in jquery/PHP?
I have a search bar like
<div id="searchbar">
<form>
<select name="Cars">
<option value="big">Big Cars</option>
<option value="small">Small Cars</option>
</select>
<input type ='text' name="searchkey" id ="search" onblur ='setTimeout('removeSearchSuggestions()', 20);' onkeyup ='getSearchSuggestions(this.value);'/>
<br/>
<div id = 'searchsuggest'></div>
<input type ='submit' value = 'Search' />
</form>
</div>
and i have the following jquery code snippet
function getSearchSuggestions(value){
if (value !=""){
$.post("searchSuggest.php", {searchPart:value}, function(data) {
$("#searchsuggest").html(data);
doSearchCSS();
});
} else {
removeSearchSuggestions开发者_运维问答();
}
}
So searchSuggest has access to "searchPart" i.e. the value that is typed into the input box. I am modifying something I got to work for a case without options. How do I modify the jquery function to access the selected option in searchSuggest.php?
Thanks!
This will help you: http://api.jquery.com/selected-selector/
精彩评论