value not store in hidden section or div............... my html : <div class="main_search_city_input_div"> //type here for search <input type="text" onblur="hide_city_section();" autocomplete="off" value="Varanasi" id="main_search_input_field" name="main_search_input_field" style="display: block;"> //hidden input field store the city name which are selected by autosuggested result <input type="hidden" value="temp" id="main_search_input_field_hidden" name="main_search_input_field_hidden"> //display result of hidden field <div class="main_search_city_show_div" style="display: none;">Varanasi</div> <div class="main_search_city_drop_down_div" style="display: block;"> //display in red color autosuggest result in div <div onclick="city_store(this.id);" id="Bareilly" class="main_search_city_drop_down_div_inn">Bareilly</div> <div onclick="city_store(this.id);" id="Etah" class="main_search_city_drop_down_div_inn">Etah</div> </div> </div> Code (markup): my javascript : function city_store(a) { $('#main_search_input_field_hidden').val(a); $('.main_search_city_show_div').html(a); $('.main_search_city_show_div').css("display","block"); $('#main_search_input_field').css("display","none"); $('.main_search_city_drop_down_div').css("display","none"); } function hide_city_section() { $('#main_search_input_field').css("display","none"); $('.main_search_city_drop_down_div').css("display","none"); $('.main_search_city_show_div').css("display","block"); } Code (markup): please help me.........................................
I suggest you rewrite that trainwreck - what, first of all, are you trying to do? Are you trying to show a certain content field based on what is being searched? And all of these options are already present on the page, just hidden? If so, you can do it like this: http://jsfiddle.net/rn9ax9b5/ Note that that doesn't really autocomplete anything, it just shows matching results - an autocomplete can be done by changing the comparison to a regex-match for text entered in the input box.
I have to agree with @PoPSiCLe that piece of code means nothing. Where is the data? Do you preload arrays? How the search works? Are you calling an external PHP to fuzzy search a db or are you using Google Autocomplete API? If it's what I think the entire "script" can be done in 6 lines of code.
$('.main_search_city_show_div').css("display","block"); $('#main_search_input_field').css("display","none"); Code (markup): Given that you are using jquery why aren't you just using .show() and .hide() ? edit: I see that @PoPSiCLe has that in his fiddle