Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
Results 1 to 2 of 2
-
03-04-2016, 11:20 AM #1New to the CF scene
- Join Date
- Mar 2016
- Posts
- 7
- Thanks
- 5
- Thanked 0 Times in 0 Posts
compare content of array and object
Hi
I have an object array . The objects are generated programmatically and their key values are added to the DOM using an array. What I would like to know is how to relocate the object from which the values emanate and remove it from its container if the array is removed from the DOM could anybody please help me?
I have
It contains three objects with the name of a continent and its population which are the values of two fieldsets name and population.Code:var continents = []
example:Code:var continent ={} continent [Name] = the value population continent [Population] = the value of name
I am not sure how to identify the object and then delete it
-
03-04-2016, 04:54 PM #2Master Coder
- Join Date
- Jan 2011
- Location
- Washington
- Posts
- 6,251
- Thanks
- 30
- Thanked 859 Times in 857 Posts
Really not sure what your asking. Your array should only have two elements the name of a continent and it's population.
And why do you want to delete anything?
And this linethrew me cause the array is part of the JS and not the DOM.if the array is removed from the DOM
Anyway here is something that might or might not help:
Code:<!DOCTYPE html> <html> <head> <title>New document</title> <style type="text/css"> #show{ display: none; } </style> </head> <body> <select onchange="doit(this.value);"> <option value="">Pick a continent</option> <option value="Asia">Asia</option> <option value="Africa">Africa</option> <option value="Antarctica">Antarctica</option> <option value="Australia">Australia</option> <option value="Europe">Europe</option> <option value="North_America">North America</option> <option value="South_America">South America</option> </select> <div id="show"> The population of <span id="in"></span> is <span id="info"></span> </div> <script> var continents = { Asia: 4164252000, Africa: 1022234000, Antarctica: 4490, Australia: 29127000, Europe: 738199000, North_America: 542056000, South_America: 392555000}; function doit(name){ document.getElementById("in").innerHTML = name; document.getElementById("info").innerHTML = continents[name]; document.getElementById("show").style.display = "block"; } </script> </body> </html>Evolution - The non-random survival of random variants.
Physics is actually atoms trying to understand themselves.
-
Users who have thanked sunfighter for this post:
princesse (03-09-2016)



Reply With Quote
