Tuesday, 22 November 2011

Using Ajax Comparsion Two Div and Select Tag

<html>
<head>
<title>Comparison</title>


<script type="text/javascript">
 function  showPage1(str){
 var xmlhttp;   
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }

xmlhttp.open("GET"," "+str+" ",true);

xmlhttp.send();

 }



 function  showPage2(str){
 var xmlhttp;   
if (str=="")
  {
  document.getElementById("txtHint2").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint2").innerHTML=xmlhttp.responseText;
    }
  }

xmlhttp.open("GET"," "+str+" ",true);

xmlhttp.send();

 }


</script>


 <div class="column1-unit" style="width:655px">
       
        <div style="width:315px; float:left">
         <select id="ourSelect" onChange="showPage1(this.value)"  style="width:150px;" >
        <option >Select a Model</option>
       <option value="HondaAccord.html" >Honda Accord</option>
       <option value="HondaCity.html">Honda City</option>
       <option value="HondaCivic.html">Honda Civic</option>
      <option value="HondaCRV.html">Honda CR-V</option>
      <option value="Mahran.html">Mahran</option>
              <option value="Cultus.html">Cultus</option>
              <option value="Swift.html">Swift</option>
              <option value="Prado.html">Prado</option>
              <option value="GLI.html">GLi</option>
              <option value="XLI.html">XLi</option>
            </select>
          </div><!--closing of select div-->
         
       
              
        <div style="width:315px; float:left">
          <div align="center">
           <select id="ourSelect" onChange="showPage2(this.value)"  style="width:150px;" >
              <option selected="selected">Select a Model</option>
              <option value="HondaAccord.html" >Honda Accord</option>
       <option value="HondaCity.html">Honda City</option>
       <option value="HondaCivic.html">Honda Civic</option>
      <option value="HondaCRV.html">Honda CR-V</option>
      <option value="Mahran.html">Mahran</option>
              <option value="Cultus.html">Cultus</option>
              <option value="Swift.html">Swift</option>
              <option value="Prado.html">Prado</option>
              <option value="GLI.html">GLi</option>
              <option value="XLI.html">XLi</option>
              <option value="ToyotaCamry.html">Camry</option>
            </select>
          </div>
         
         

         
         
        </div>
        <div id="txtHint" Style="width:315px;  height:315px; float:left; overflow:scroll; "   >Customer info will be listed here...</div>
<div id="txtHint2" Style="width:325px;  height:315px; float:left; margin-left:10px; overflow:scroll;" >Customer info will be listed here...</div>
       
           <!--/header-->
        
        </div>
                                                                     

    
</body>
</html>

No comments:

Post a Comment