I am building a form in HTML out of a javascript object that I've imported from a JSON file. I use a recurisve algorithm to build HTML tables, and respective elements (labels, text boxes, etc.) The fields load with the value of the current node.
The idea is to edit the values in the textboxes; which in turn updates the javascript object. When changes have been made, the editor will send the JSON object to the server and update the file.
The puzzling question, is how do I reference the node that has been changed? I have tried several approaches to no avail.
EDIT:
This is a basic idea of what I'm doing:
function build_tree(obj, depth) {
for (key in obj) {
if (typeof(obj[key]) == 'object') {
print(key + "<input type="text" value='" + obj[key] + "'>");
build_tree(obj[key], depth + 1);
} else
print(key + "<input type="text" value='" + obj[key] + "'>");
}
Now, how do I bind the value of obj[key] to the text boxes, so that when I change the value it updates the Javascript object?
Definition and Usage. The <object> tag defines a container for an external resource. The external resource can be a web page, a picture, a media player, or a plug-in application. To embed a picture, it is better to use the <img> tag. To embed HTML, it is better to use the <iframe> tag.
An object element contains elements for the object fields. Each object element can contain one or more attributes. The following table lists the attributes that can apply to an object element. Attribute names and values are case-sensitive. All attributes are optional.
In summary, we can store JavaScript objects in localStorage by first converting them to strings with the JSON. stringify method, then back to objects with the JSON. parse method.
document.getElementById('name').changed = true;
So now the DOM element has the property 'changed'. You can also use any other value (dates, arrays, etc)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With