Jump to content

Append to Table


savagenoob

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/184745-append-to-table/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.