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 9226919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:56:35+00:00 2026-06-18T04:56:35+00:00

I am looking form a nested data to a DOM element. Something like this

  • 0

I am looking form a nested data to a DOM element. Something like this

$("div").data( "test", { 
    first: 16,
    last: "pizza!"
});

Here is my effort to make similar kind of format. But RefAttrValue variable is not behaving as variable.

for (var i = 0; i < reference.attributes.length; i++) {
    var RefAttrValue = (reference.attributes.item(i).name);
    $(tableCaption).data("referenceData").RefAttrValue = reference.attributes.item(i).value;
}

Here the Values of the “reference” is a XML. Which has value like below or can contain any similar XML.

<facilityreference Name="qtitem_fac" AttrTable='table1' colVal='table1colValue'></facilityreference>

I want to set up the data() format in this below format “Dynamically”.

$("div").data("test",{ Name: "qtitem_fac", last: "table1colValue" });

Please help.

  • 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-06-18T04:56:37+00:00Added an answer on June 18, 2026 at 4:56 am

    As far as I understand, you need something like this:

    var datObj = {};
    for (var i = 0; i < reference.attributes.length; i++) {
        var RefAttrValue = (reference.attributes.item(i).name);
        datObj[RefAttrValue] = reference.attributes.item(i).value;
    }
    $(tableCaption).data("referenceData", datObj );
    

    In your code I see few problems:
    First: If you do nothing like $(tableCaption).data("referenceData", {...}) before you run your code, line $(tableCaption).data("referenceData") will return undefined and that will cause an exception.

    If you have a field name in a variable (RefAttrValue in your case) you need to do something like $(tableCaption).data("referenceData")[RefAttrValue]. Such notation is a synonym, if RefAttrValue = "Name", to $(tableCaption).data("referenceData").Name

    Doing this $(tableCaption).data("referenceData").RefAttrValue you simply access property of referenceData with name RefAttrValue.

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

Sidebar

Related Questions

I'm looking to align one of my <div> containers which has a nested <form
I am trying to dynamically form a nested tree object something like below using
I'm looking to enable saving of form data prior to submission. I want users
I'm looking for a way to send some hidden form-data to a Django-server, which
I am looking to insert data from a PHP form in to an XML
Trying to customize Symfony2 form to produce html code looking like the following example:
I'm looking for something similar to the table creation form from phpmyadmin, but it
I have been looking at a couple html/css form frameworks like Uni-Form and Formy
Im looking for the proper way to build a form for the following data
I need assistance in accessing a nested array located my JSON Data Set. Here

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.