views:

66

answers:

1

Hi

I have found the following code to create a search on my site - this works really well the only problem is in Internet Explorer the search doesn't work when you press the return key.

Does anybody have any ideas?

The search code is below - if anything else is needed please let me know.

$(function() 
{
$(".search_button").click(function() 
{
var search_word = $("#search_box").val();
var dataString = 'search_word='+ search_word;

if(search_word=='')

{
}
else
{
$.ajax({
type: "GET",
url: "searchdata.php",
data: dataString,
cache: false,
beforeSend: function(html) 

{
document.getElementById("insert_search").innerHTML = ''; 
$("#flash").show();
$("#searchword").show();
$(".searchword").html(search_word);
$("#flash").html('<img src="ajax-loader.gif" /> Loading Results...');

},

success: function(html){
$("#insert_search").show();
$("#insert_search").append(html);
$("#flash").hide();

}


});


}
return false;
});
});
A: 

Could you place up your markup as well, for the actual form?

I have a niggling suspicion based on a similar problem with IE. As we all know IE is a horrible browser and you have to break your back to accommodate it.

Depending on your markup, and that the fact your event is called on a click on a class, within your form markup you may need to have your submit element be an actual submit input type in order for the keyboard triggering elements to work.

Modern browsers are very intelligent, but IE needs a carrot every now and then.

duckbox
Here is the form code:<form method="get" action=""><p> <input name="search" type="text" class='search_box' id="search_box" value="<?php $_POST['#searchword']; ?>"/> <br> <label> <input type="submit" value="All" class="search_button" /> </label></form> </div> <div> <div id="searchword">Search results for <span class="searchword"></span></div> <div id="flash"></div> <ol id="insert_search" class="update"> </ol> </div> </div>If you need further info please let me know.
Haribo83
Odd, I have all pieces of code in a test file. Ie6 - 8 works in terms of the return key. Do you have this on a live link?
duckbox