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, maybe someone could help out. I basically just want to create a new <div> showing the driver just added to the database but leave the previous one as well.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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