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...

Recommended Answers

All 2 Replies

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);
    });
});

Im sorry did you not like my answer? It pretty much solves your question? @accra

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.