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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:54:34+00:00 2026-06-03T20:54:34+00:00

I have two DND conatainers, SourceContainer and TargetContainer SourceContainer have some json data e.g:

  • 0

I have two DND conatainers, SourceContainer and TargetContainer
SourceContainer have some json data e.g:

Apple 
Orange 
Banana

using following Json:

var json = {"fruits": [
           {"fruitId": 1, "fruitName": "Apple", "fruitDesc": "This is an Apple"},
           {"fruitId": 2, "fruitName": "Orange", "fruitDesc": "This is an Orange"},
           {"fruitId": 3, "fruitName": "Banana", "fruitDesc": "This is a Banana"}
        ]
    };

var results="";
   for(var i=0;i<json.fruits.length;i++){
     results += '<div class="dojoDndItem ">' + '<span style="visibility: hidden">' + json.fruits[i].fruitId + '</span>' + json.fruits[i].fruitName  + '</div>';
   }

My SourceContainer

<div><label>Fruits</label></div> 
<div dojoType="dojo.dnd.Source" id="source1" copyonly="false" delay="8" class="container dojoDndSource dojoDndTarget dojoDndContainer">
<div dojoType="dojo.dnd.Source" ></div> results </div>

My TargetContainer

<div><label>Basket</label></div>
<div dojoType="dojo.dnd.Source"  id="source2" copyonly="false" descending="true" delay="8" class="container dojoDndSource dojoDndTarget dojoDndContainer">
<div dojoType="dojo.dnd.Source" ></div>
</div>

<button id="toJsonBtn" data-dojo-type="dijit.form.Button" type="button">ToJson</button>

Now when I drag “Apple” and Banana to the TargetContainer and click the button, I want the data in TargetContainer to convert in Json.

Any idea for doing so. Appreciate any help. Thank you

NOTE: Force not to use JQuery 🙁

  • 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-03T20:54:35+00:00Added an answer on June 3, 2026 at 8:54 pm

    I figured it out how to solve it. Below is the solution if some one interested;

    Our Json

    var json = {"fruits": [
                   {"fruitId": 1, "fruitName": "Apple", "fruitDesc": "This is an Apple"},
                   {"fruitId": 2, "fruitName": "Orange", "fruitDesc": "This is an Orange"},
                   {"fruitId": 3, "fruitName": "Banana", "fruitDesc": "This is a Banana"}
                ]
            };
    

    Items in target container

    Apple 
    Orange 
    Banana
    

    Create Target Container

    var fruitListContainer = new dojo.dnd.Source("fruitNode");
    
    dojo.connect(dojo.byId('toJsonBtn'), 'onclick', function() {
      var target_container = fruitListContainer.getAllNodes();
      var fruit_arr = [];
      for(var i=0;i<target_container.length;i++){
          var fruit_results = target_container[i].childNodes[0].nodeValue;
          roles_arr.push(fruit_results);
      }
    var result={};
    result["fruits"]=fruit_arr;
    alert(JSON.stringify(result));
    

    And the alert output will be (which is required):

    {"fruits":["Apple","Orange","Banana"]}
    

    Note: If there any explanation needed, I am happy to help.

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

Sidebar

Related Questions

I have two queries, as following: SELECT SQL_CALC_FOUND_ROWS Id, Name FROM my_table WHERE Name
I have two Hibernate data object. The first is a User (with unique id,
Have two sets of data (two tables) for patient records, one 1999-2003, the other
I have two applications written in Java that communicate with each other using XML
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
Have two variables both containing integers: var input; var value; Need to perform arithmetic
I have two tables of data categories and category relations. This is a setup
I have two tables in a MySQL database. In the first column of data
We have two identical installations of CF9 (C:/inetpub/wwwroot/cfide/...) using the FCKeditor. One is the
My JavaScript code is as below //I have a Json: var jsonRoles = {"roles":

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.