logo
down
shadow

Creating a dynamic array within a dynamic array in JQuery


Creating a dynamic array within a dynamic array in JQuery

By : mazeRunner
Date : November 29 2020, 09:01 AM
To fix the issue you can do You can extract all steps using querySelectorAll. Then, iterate through all steps in this collection and gather name, id and courses using querySelector.
Array.prototype.map will make iteration easier.
code :
var stepElements = document.querySelectorAll('.si-steps');

var result = [].map.call(stepElements, function(stepElement) {
  var courseElements = stepElement.querySelectorAll('.si-courses');
  
  var coursesInfo = [].map.call(courseElements, function(courseElement) {
    return {
      'course-name': courseElement.querySelector("[name='course-name']").value,
      'course-id': courseElement.querySelector("[name='course-id']").value
    };
  });
  
  return {
    'step-name': stepElement.querySelector("[name='step-name']").value,
    'step-id': stepElement.querySelector("[name='step-id']").value,
    'course': coursesInfo
  };
});
  
document.getElementById('result').innerText = JSON.stringify(result, null, 4);
<div class="si-steps">
  <input type="text" class="si-step-input" name="step-name" value="step1">
  <input type="text" class="si-step-input" name="step-id" value="1">
  <div class="si-courses">
    <input type="text" class="si-step-input" name="course-name" value="course1">
    <input type="text" class="si-step-input" name="course-id" id="c1">
  </div>
  <button type="button" id="si-course-btn" class="si-course-btn">Add course</button>
</div>

<div class="si-steps">
  <input type="text" class="si-step-input" name="step-name" value="step2">
  <input type="text" class="si-step-input" name="step-id" value="2">
  <div class="si-courses">
    <input type="text" class="si-step-input" name="course-name" value="course3">
    <input type="text" class="si-step-input" name="course-id" id="c3">
  </div>
  <button type="button" id="si-course-btn" class="si-course-btn">Add course</button>
</div>

<button type="button" id="si-step-btn" class="si-step-btn">Add step</button>

<div>
  <pre id="result">
  </pre>
</div>


Share : facebook icon twitter icon
Jquery creating associative array with dynamic keys and multiple values

Jquery creating associative array with dynamic keys and multiple values


By : Bruno Tezine
Date : March 29 2020, 07:55 AM
should help you out Based in the comments I think what you need is:
obj["newProp"] = []; // A new property is added to the object with key newProp and an empty array as value obj.newProp.push(newElement); // A new element is added to the array in newProp of object
creating dynamic array in a dynamic javascript object (key/value pair)

creating dynamic array in a dynamic javascript object (key/value pair)


By : user2950215
Date : November 17 2020, 11:52 AM
Any of those help You indeed need to check if the key is present in finalData.queryData and if not create. Look at this solution:
code :
var addJiraData = function (queryKey, extractedData) {
    if (!finalData.queryData[queryKey] || !finalData.queryData[queryKey]["jiraDetail"])
    {
        //one of the objects isn't present, let's create it.
        !finalData.queryData[queryKey] ? addJiraList(queryKey, []) : null; //add missing queryKey and empty array as jiraList.
        finalData.queryData[queryKey]["jiraDetail"] = []; //create empty jiraDetail array.
    }
    //then fill it with data, since it is available now.
    finalData.queryData[queryKey]["jiraDetail"].push(extractedData);
};
declare dynamic array based on dynamic variables in jquery

declare dynamic array based on dynamic variables in jquery


By : Johnny_Blue
Date : March 29 2020, 07:55 AM
it helps some times This an array , Well, this is easy:
code :
var DATES=[];for (var i=0;i<mlength;DATES.push([]),i++);
how to create dynamic array and adding dynamic values using jQuery.

how to create dynamic array and adding dynamic values using jQuery.


By : Bálint Csonka
Date : March 29 2020, 07:55 AM
hop of those help? I am the beginner in jQuery. how to create the dynamic array and adding dynamic values using jQuery. currently, I'm on this. I'm getting this on StackOverflow , You can do it :
Create table
code :
$("#my_id_container").html("<table><thead></thead><tbody></tbody></table>");
<div id="my_id_container"></div>
$("#my_id_container").find('table tbody').append('<tr>My new ligne</tr>');
C++: creating a dynamic array using dynamic memory

C++: creating a dynamic array using dynamic memory


By : Jennifer
Date : March 29 2020, 07:55 AM
I hope this helps you . I'm trying to create a dynamic array or what should you call that, using pointer, but when I try to cout the length of the array after setting the elements, it gives me 0. I'm not sure what I'm doing wrong here. , Better use the stl vector, this have the size() method
Related Posts Related Posts :
  • CRM 2013 Limit the date field
  • fancybox - changing close button color
  • Ember-notify giving error can't read property "Service" of undefined
  • Passport-init.js authentication is not working in nodejs
  • Branch.io Cordova API - init() fails on Android Device
  • appending HTML codes to an elements using js
  • Css animation to extend button text on hover
  • I want to restrict HTML input autocomplete to 3 letter minimum
  • tinyMCE editor not updating on the fly
  • typescript kendo-ui call method from string
  • HttpCompileException was unhandled by user code (when i am adding c# code in script)
  • Send form data as array of objects to controller in asp.net mvc
  • Javascript, multi file modules and Require.Js
  • how to render a complete new template and leave the application template in ember
  • Hover unrelated divs
  • Permute string until it matches some input?
  • How to fire JQuery change event when input value changed programmatically?
  • AJAX: POST data to a different url
  • checkbox column in jquery datatable
  • Document.evaluate for documents without namespaceURI crashes Microsoft Edge
  • Bootstrap Menu with "More" option Responsive issue
  • Standard inputs not being added to Angularjs Form $Scope
  • Express promise throw error
  • onclick and get in jquery
  • How to get the country code from Google Places API
  • Passing parameters url in Select2
  • Is there any frame work for Marklogic to write javascript code?
  • How to implement a boostrap template over bootstrap-sass gem
  • Why fixed div comes out when horizontally scrolled?
  • How to limit scope of a function in javascript/ jquery
  • Overlapping legend d3.js
  • Apply transition to div
  • Javascript game help - counting with dice
  • How to hide a div from angular controller
  • Can Promise load multi urls in order?
  • How enable Hover event for bootstrap menus?
  • D3 scale.invert() isn't returning date for x
  • Parsing object to array using underscore js or lodash
  • ES6 with React and Browserify
  • AngularJS Factory return type undefined
  • javascript follow html input fields
  • how to declare a double array in javascript for this particular UI
  • Jquery : find length of mixed list
  • Returning the array before the function is complete & Angular JS
  • Javascript set value of class & hidden input in nested divs
  • Register custom filters with vue.js
  • Add class to input parent
  • Angular controller not talking to view
  • Trouble creating "if then" Javascript statement to change background color of page
  • Socket.IO - Middleware and scoping: how should I access global IO object from external middleware?
  • add class when input is valid in angularjs
  • Positioning multiple div elements
  • Checkbox clicking works, deselecting checkbox not working Javascript
  • Adding ajax jQuery File upload
  • Multiple File Upload actions for a single File Input PHP/JS
  • Want to move an added element to a different part of the DOM
  • Why can't I get Angularjs to work?
  • Minimizing browser window in Firefox & Chrome adds white space to right of page
  • I need to insert the date and time of employee stamp in and out into mysql database
  • Making css auto slider
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co