0

i have this ajax script

    <script type="text/javascript"> 
        var url = "GetAutoData.php?svreg="; // The server-side script 
       function handleHttpResponse() {    
        if (http.readyState == 4) { 
              if(http.status==200) { 
                  var results=http.responseText; 
              document.getElementById('divAutoInfo').innerHTML = results; 
              } 
              } 
        } 

        function requestAutoInfo() {      
            var svreg = document.getElementById("getautomobile").value; 
            http.open("GET", url + escape(svreg), true); 
            http.onreadystatechange = handleHttpResponse; 
            http.send(null); 
        } 
function getHTTPObject() { 
  var xmlhttp; 

  if(window.XMLHttpRequest){ 
    xmlhttp = new XMLHttpRequest(); 
  } 
  else if (window.ActiveXObject){ 
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    if (!xmlhttp){ 
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    } 
} 
  return xmlhttp; 
} 
var http = getHTTPObject(); // We create the HTTP Object 
</script>      

with this html script

Automobile #: <input type="text" id="getautomobile" value="" />
<input type="button" value="Get Automobile Info" onclick="requestAutoInfo()" />
<div id="divAutoInfo"></div> 

Am trying to add a secound field "Automobile #2:<input type="text" id="getautomobile2" value="" />" to the html part and send it to mysql through the above ajax script,but am at a lost.Pls help me out...

Edited by accra

2
Contributors
2
Replies
16
Views
3 Years
Discussion Span
Last Post by gabrielcastillo
1

Try this:

 var svreg = document.getElementById("getautomobile").value;
 var svreg2 = documnet.getElementById('getautomobile2').values;

http.open("GET", url + escape(svreg) + "&param=" + escape(svreg2), true); 

Personally I would use jquery.Jquery makes it realy easy to use ajax.

jQuery(document).ready(function($){
    $.post('someurl', {param1: $('#id1').val(), param2: $('#id2').val();}).done(function(data){
        console.log(data);
    });
});
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.