Jump to content

Search as you Type - working in Firefox, but not IE


Recommended Posts

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

 

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"

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.