Jump to content

ajax php mysql


itgetsharder

Recommended Posts

Hi, im pretty new to this. basically, i have two database tables in mysql, one called items(id of the book, cookieid, quantity) and the other books(id, name, desc, price). my php returns xml(name, price, quantity and total amount). my code returns the name and price but i can't get it to return the quantity or total.

 

can anyone see any errors in my code? i think the problem is with the quantity which is the variable newCell2. I keep getting the error "object expected" with that part in IE. 

 

if (request.readyState==4) {
    		if(request.status==200) {

		var response =request.responseXML;
for(var i=0; i<=response.getElementsByTagName('store').length; i++)
{
var newRow = document.getElementById('table').insertRow(-1); // Insert the third row
                    var newCell1 = newRow.insertCell(0); // Insert the first cell
                    newCell1.innerHTML = response.getElementsByTagName('book')[i].childNodes[1].childNodes[0].nodeValue; // First cell's innerHTML
                    var newCell3 = newRow.insertCell(2); // Insert the second cell
                    newCell3.innerHTML = response.getElementsByTagName('book')[i].childNodes[3].childNodes[0].nodeValue;
                    var newCell2 = newRow.insertCell(1); // Insert the second cell
                    newCell2.innerHTML = response.getElementsByTagName('book')[i].childNodes[4].childNodes[0].nodeValue; // Second cell's innerHTML
                    var newCell4 = newRow.insertCell(3); // Insert the second cell
                    newCell4.innerHTML = response.getElementsByTagName('book')[i].childNodes[5].childNodes[0].nodeValue;
}

 

thanks in advance.

Link to comment
Share on other sites

  • 2 weeks later...
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.