tsoltysiak Posted September 28, 2010 Share Posted September 28, 2010 Hi, I have an Ajax script that filters results onKeyUp, but it does not work for me in IE (I've just tried using IE 8, haven't tried others yet). It works fine in Firefox. The thing is, I'm using a very similar script for another search as you type Ajax update filter, which works in both Firefox and IE. I'm not sure is there something wrong with my script, or just my IE isn't working properly. Here is the code for it: Javascript: <script language="javascript" type="text/javascript"> function ajaxListSearchSpecialFunction(s){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var SearchListDisplay = document.getElementById('searchspeciallist'); SearchListDisplay.innerHTML = ajaxRequest.responseText; } } var s = document.getElementById('specialsearchbox').value; var queryString = "?s=" + s + "&categoryid=<?php echo $categoryid;?>"; ajaxRequest.open("GET", "searchspeciallist.php" + queryString, true); ajaxRequest.send(null); } </script> The form that people type into <form name="listfilterspecialform" method="get"> <input type="hidden" name="categoryid" value="<?php echo $categoryid;?>"> <input class="largesearch" type="text" id="specialsearchbox" autocomplete="off" value="<?php if(isset($_GET['s'])) {echo $_GET['s'];} else {echo "Search Airlines";}?>" name="s" onfocus="if(this.value=='Search Airlines')this.value='';" onblur="if(this.value=='')this.value='Search Airlines';" onkeyup="ajaxListSearchSpecialFunction('');"/> </form> The part of the table that is meant to be uploaded <tbody id="searchspeciallist"> <?php include "searchspeciallist.php"?> </tbody> I'm not sure why it's not working in IE? If you want to test it out, it can be found over here: http://www.airline-luggage-regulations.com/special.php?flywith=Bikes&categoryid=1 The Search as you Type field in the left column is working. It's the one in the main column, that filters the table with bike policies, is the one that is not working. The thing is, I'm using the same code for both, with just a different variable for the search query. Any ideas? Thanks a lot, Tom Quote Link to comment https://forums.phpfreaks.com/topic/214649-search-as-you-type-working-in-firefox-but-not-ie/ Share on other sites More sharing options...
RichardRotterdam Posted September 29, 2010 Share Posted September 29, 2010 Works fine for me in ie 8 and ie 7. Did you mean ie 6? I do get a syntax error on line114 which is: function replaceDefault(el){ if (el.defaultValue==el.value)} el.value = "Search Airlines" Quote Link to comment https://forums.phpfreaks.com/topic/214649-search-as-you-type-working-in-firefox-but-not-ie/#findComment-1117127 Share on other sites More sharing options...
tsoltysiak Posted September 29, 2010 Author Share Posted September 29, 2010 It was IE8, turns out that IE doesn't like writing to tables, so I had to move the entire table to the dynamic site and refresh the entire table, not just the tbody. Haven't tested in IE6, but I'm sure it didn't like the old version of the code either. haha. As for the syntax error, fixed that as well, the curly bracket was closed too soon, was supposed to be after "search airlines", not before. Tom Quote Link to comment https://forums.phpfreaks.com/topic/214649-search-as-you-type-working-in-firefox-but-not-ie/#findComment-1117331 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.