savagenoob Posted December 11, 2009 Share Posted December 11, 2009 I have an ajax script that dynamically displays data submitted from a form. I was wondering how to append to the bottom of the display with every form submit. In my script it inserts new driver information and returns the information for display. Here is the Javascript for the process: function ajaxFunction(){ var ajaxRequest; 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; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var firstname = document.getElementById('firstname').value; var middlename = document.getElementById('middlename').value; var lastname = document.getElementById('lastname').value; var datebirth = document.getElementById('datebirth').value; var gender = document.getElementById('gender').value; var marstatus = document.getElementById('marstatus').value; var licnum = document.getElementById('licnum').value; var licstate = document.getElementById('licstate').value; var licstatus = document.getElementById('licstatus').value; var transid = document.getElementById('transid').value; var queryString = "?firstname=" + firstname + "&middlename=" + middlename + "&lastname=" + lastname + "&datebirth=" + datebirth + "&gender=" + gender + "&marstatus=" + marstatus + "&licnum=" + licnum + "&licstate=" + licstate + "&licstatus=" + licstatus + "&transid=" + transid; ajaxRequest.open("GET", "adddriver.php" + queryString, true); ajaxRequest.send(null); } //--> I think I could use appendChild somewhere but dont know where or how to put it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.