javascript - 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">
<select name="Cars">
<option value="big">Big Cars</option>
<option value="small">Small Cars</option>
<input type ='text' name="searchkey" id ="search" onblur ='setTimeout('removeSearchSuggestions()', 20);' onkeyup ='getSearchSuggestions(this.value);'/>
<div id = 'searchsuggest'></div>
<input type ='submit' value = 'Search' />

and i have the following jquery code snippet

function getSearchSuggestions(value){
   if (value !=""){
   $.post("searchSuggest.php", {searchPart:value}, function(data) {
   } else {


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?





This will help you:

People are also looking for solutions to the problem: php - How to change attribute value on a simpleXML element?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.