Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7170217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:09:59+00:00 2026-05-28T15:09:59+00:00

I am building a form in HTML out of a javascript object that I’ve

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:10:01+00:00Added an answer on May 28, 2026 at 3:10 pm

    First off you need a way to individually identify the input so, i would add a data-key attribute.

    function build_tree(obj, depth) {
        for (key in obj) {
            if (typeof(obj[key]) == 'object') {
                print(key + "<input type="text" value='" + obj[key] + "' data-key= '"+key+"'>");
                build_tree(obj[key], depth + 1);
            } else 
                print(key + "<input type="text" value='" + obj[key] + "' data-key= '"+key+"'>");
    } 
    

    Then i would attach a change event handler to each text input, after the tree is built.

    $('input[type="text"]').on('change',function(){
       var key = $(this).data('key'); 
       obj[key] = $(this).val(); 
    }); 
    

    obj would be a global array. Hope this makes sense.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing a JSON response via $.ajax() and building a form from this object's
I'm building a dynamic ExtJS form based on JSON data loaded from an ASP.NET
So I have a large JSON object i'm returning from the server, then building
I am building a survey, in which participants use a html form to enter
Suppose you're building an HTML form and you want to have 2 or more
I'm currently building a web form using APEX that is losely modelled after a
I'm building a web page form with jquery append() , html() etc and I'm
I'm building an HTML form with which the user should be able to upload
I was building a simple web based calculator which takes equations from a HTML
We have some html that looks like this: <form id=MyUserControl runat=server method=post> <script language=javascript

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.