SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2006
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Script won't work in IE but is perfect in Firefox

    The script and partial html below is supposed to populate the options in a select list depending on the option chosen in the previous select.

    The script calls a PHP script "getmodels.php" to query a database and select car models using the selected make as the search string.

    Using a firefox browser, this all works perfectly but using IE the call to the PHP script does not seem to happen.

    Here is the script and HTML as far as the form elements:

    Code:
    <html>
    
    <head>
    <title>car dealer used and pre-owned cars and trucks in Reno Nevada</title>
    <script type="text/javascript">
    <!--
    var xmlHttp
    
    function getModel(str)
    {
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
     {
     alert ("Browser does not support HTTP Request")
     return
     }
    var url="getmodels.php"
    url=url+"?q="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=stateChanged
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    }
    
    function stateChanged()
    {
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
     {
     document.getElementById("model").innerHTML=xmlHttp.responseText
     }
    }
    
    function GetXmlHttpObject()
    {
    var xmlHttp=null;
    try
     {
     // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
     }
    catch (e)
     {
     //Internet Explorer
     try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
     catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
     }
    return xmlHttp;
    }
    // -->
    </script>
    </head>
    
    <body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
    <table border="0" width="760" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td width="760" colspan="2" height="110" align="right" valign="middle" background="images/top_logo.gif"><a href="http://siteurl" target="_blank">Home</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://siteurl/contact.html" target="_blank">Contact us</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://siteurl">About Us</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/bbb.gif" /></td>
        </tr>
        <tr>
            <td width="151" height="50" align="center" valign="middle" background="button_back.gif"><a href="#cars">See our Cars!</a></td>
            <td width="609" rowspan="6" height="283" background="images/main_1.jpg">&nbsp;</td>
        </tr>
        <tr>
            <td width="151" height="50" align="center" valign="middle" background="button_back.gif"><a href="http://siteurl/credit_app.php" target="_blank">APPLY for CREDIT</a></td>
        </tr>
        <tr>
            <td width="151" height="50" align="center" valign="middle" background="button_back.gif"><a href="http://siteurl/directions.html" target="_blank">Directions</a></td>
        </tr>
        <tr>
            <td width="151" height="50" align="center" valign="middle" background="button_back.gif"><a href="http://siteurl" target="_blank">Store Hours</a></td>
        </tr>
        <tr>
            <td width="151" height="50" align="center" valign="middle" background="button_back.gif"></td>
        </tr>
        <tr>
            <td width="151" height="33" align="center" valign="middle" background="bottom_button_back.gif">&nbsp;</td>
        </tr>
        <tr>
            <td width="760" colspan="2" height="110" bgcolor="#FDFD00">
                <p align="center"><b><font face="Arial" size="4">Welcome to Reno NV's used car specialist!  Find your next used car, truck or suv right here at Reno Nevada.</font></b>
    We know you'll find what you're looking for at our quality used car dealership. Feel free to browse our inventory or search for a specific vehicle. We also offer great financing with low monthly payments.</p>
            </td>
        </tr>
        <tr>
            <td width="760" height="110" colspan="2" bgcolor="#FDFD00">
                <p align="center"><form name="search" method="post" action="search.php" target="_blank">
                <font color="#990000"><b>Search by price!</font></b>
                Min$:<input type="text" name="min" maxlength="7" />
                Max$:<input type="text" name="max" maxlength="7" />
                <input type="submit" name="Submit" value="Search" alt="Search for used cars by price range at dealersite" /></form></p>
            </td>
        </tr>
        <tr>
            <td width="760" height="110" colspan="2" bgcolor="#FDFD00">
                <p align="center"><form name="search_make" method="post" action="search_make.php" target="_blank">
                <font color="#990000"><b>Search by Make and Model!</font></b>
                <select name="make" onchange="getModel(value)">
                <option value="any">Any</option>
                <option value="BMW">BMW</option>
    <option value="Chevy ">Chevy </option>
    <option value="Chrysler">Chrysler</option>
    <option value="Dodge">Dodge</option>
    <option value="Ford">Ford</option>
    <option value="GMC">GMC</option>
    <option value="Honda">Honda</option>
    <option value="Hyundai">Hyundai</option>
    <option value="Jeep">Jeep</option>
    <option value="Kia">Kia</option>
    <option value="Lexus">Lexus</option>
    <option value="Lincoln">Lincoln</option>
    <option value="Mazda">Mazda</option>
    <option value="Saturn">Saturn</option>
    <option value="Toyota">Toyota</option>
    <option value="VW">VW</option>
    </select>
                 <select id="model" name="model">
                <option id="models" value="any">Any</option>
                </select>
                <input type="submit" name="Submit" value="Search" alt="Search for used cars by price range at dealersite" /></form></p>
            </td>
        </tr>
    </table>
    Last edited by alhefner; Nov 18, 2008 at 21:39. Reason: clear up the issue a bit

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    What version of IE are you having trouble with? IE7 should be following the same path through the code as Firefox, Opera, and Safari. It is only IE4 thru 6 that need the activeX.

    If you are having trouble on an older version of IE you need to check that activeX is enabled as well as activeScripting for the call to work.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2006
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's IE7. I thought perhaps the doctype declaration may have had something to do with it but that doesn't seem have much effect.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •