开发者

How can I submit a DOM table to php?

开发者 https://www.devze.com 2022-12-25 10:30 出处:网络
I have a <table> in a web page that I populate using JavaScript code like this: var cellBarcode = row.insertCell(1);

I have a <table> in a web page that I populate using JavaScript code like this:

var cellBarcode = row.insertCell(1);
var textNode = document.createTextNode(barcode);
cellBarcode.appendChild(textNode);
var cellItemName = row.insertCell(2);
var textNode = document.createTextNode(itemName);
cellItemName.appendChild(textNode);

I need to save its data to my database... So I need to know how I can submit it to php... Is it possible...? If yes, please p开发者_如何学Pythonrovide some sample codes that are easy to understand for a beginner like me... thanks...


Yes, you can submit this information to a server-side script, but not without extra JavaScript code.

The extra JavaScript code would collect the information in the table (either from the DOM you've built, or by accessing the same data you used when building the table) into a string, which can then be sent to the server using one of standard ways.

Since you've used the term "submit", I'm assuming you want to send the table's data as part of an HTML <form> submission, you can put the generated string in an <input type="hidden"> element.

0

精彩评论

暂无评论...
验证码 换一张
取 消