Jump to content

Search the Community

Showing results for tags 'arrays'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 10 results

  1. Hello - first time posting. I've searched the forums to see if anyone else had the same question, with no luck. I'm going through the lessons in the tutorial but I can't figure out what's going on in part of the JS Type Conversion lesson. I'll link to the full lesson here, but below is the part I'm having trouble with: (mainly the function) I have no idea what's happening in the function... could someone be kind enough to break it down in detail for me? I understand how arrays work. But the function here has me stumped. Thanks so much
  2. I was fiddling with „Accessing Arrays with Named Indexes“ section examples of the Javascript tutorial and run into a situation I cannot explain. In short, I create an array 'person', then add elements to the array by index, and then add a third element by name. According to the tutorial, this should convert the array to an object (see here: https://www.w3schools.com/js/js_mistakes.asp) . Instead, after this I can access the variable 'person' as both an array (with two elements) and an object (or rather, a person.age property of the object). typeof 'person' reports: object. var person = []; person[0] = "John"; person[1] = "Doe"; person["age"] = 46; Here is a link to the full test: https://www.w3schools.com/code/tryit.asp?filename=GHWE7BWHX1GH Could someone explain what is happening here?
  3. Hello, I'm a total novice to HTML and am currently working on a really basic page: The user inputs a name into a form, and then based on their input, the page displays a series of images. Each character of the name corresponds to a different image output. My initial idea for this was to store the value of each character of the name into an array, and then sequentially output the corresponding images. However, I can't seem to find a way to store the input into an array, let alone one character at a time. Any help would be much appreciated!
  4. I have four items in an object and want to store the result in an array. I want to add objects to the array and access the individual items in an object within the array. Isobject_in_array_project.htmlobject_in_array_project.htmlobject_in_array_project.html this possible. some literature says yes and other says no. Basicly a database in memory is what I am trying to do.
  5. smus

    Array cloning

    Sorry for stupid question. I can't understand the purpose of cloning an array in JS. Why do we need it? What is the difference between: let a = []; let b = a; and: let a = []; let b = a.slice(0);
  6. I recently used PHP's json_encode( ) function to covert an array created with PHP into a JSON encoded object, as the conversion appeared normal, I then assigned the value to a Javascript variable using PHP's echo construct and reproduced it with a JS alert. This too, appeared normal. My difficulty arose when I tried using the jQuery .map( ) method to convert my nested Javascript object into a nested Javascript array. I received the following error message in my Console: TypeError: e is not an Object. (evaluating 't-1 in e') Am I being foolish to believe that I need a nested array when I already have a nested object? If not, is there not a routine to perform this very conversion?
  7. Hello, I'm trying to make some kind of leaderboard, such as the example below: var game = ["Dominoes",95,"Cards",22,"Chess",65]; The idea is to try to group all of the numbers together in the array so that I can return a position on them. For example: 95 - would return 1st place (for the most points) 65 - 2nd place 22 - 3rd place But the numbers in the "game" variable would also need to be linked in with the games so that if they were sorted numerically then the games would follow suit as well. Would anyone be able to help with this, please? I'd be grateful for any assistance. Many thanks,Dan.
  8. Hello internet, There is a webpage I would like to start building but I need to be able to pull data from other webpages. The information is public info so it’s nothing sketchy but I don’t know where to start. I began with just doing google searches but it appears it is more involved than I originally thought. If you have any recommendations on tutorials or Forum discussions I would be grateful. Thanks.
  9. Hi, I am fairly new to javascript and still finding my feet so if i am not been clear in my question let me know. I am using the chart.js to build graphs in my docuemnts and it works great, I am now trying to expand this by linking to an xml file I have set up. If I use the following code I can retrieve the data fine: xmlDoc=loadXMLDoc("rego.xml");var nSubOrg = xmlDoc.getElementsByTagName('SubOrg');var nRev = xmlDoc.getElementsByTagName('Revenue');var nCol = xmlDoc.getElementsByTagName('Colour');var nHL = xmlDoc.getElementsByTagName('HLight'); //chart data for Chart.JS var dData = [ { value: (nRev[0].childNodes[0].nodeValue), color: (nCol[0].childNodes[0].nodeValue), highlight: (nHL[0].childNodes[0].nodeValue), label: (nSubOrg[0].childNodes[0].nodeValue) }, { value: (nRev[1].childNodes[0].nodeValue), color: (nCol[1].childNodes[0].nodeValue), highlight: (nHL[1].childNodes[0].nodeValue), label: (nSubOrg[1].childNodes[0].nodeValue) }, { value: (nRev[2].childNodes[0].nodeValue), color: (nCol[2].childNodes[0].nodeValue), highlight: (nHL[2].childNodes[0].nodeValue), label: (nSubOrg[2].childNodes[0].nodeValue) }]; However I am trying to make this a bit more functional so want to loop through to create the multidimension array. I have found other snippets which gve me an idea about how to do this but I just can't get it work. I think something like this should but can't get my head round the exact syntax: xmlDoc=loadXMLDoc("rego.xml");var nSubOrg = xmlDoc.getElementsByTagName('SubOrg');var nRev = xmlDoc.getElementsByTagName('Revenue');var nCol = xmlDoc.getElementsByTagName('Colour');var nHL = xmlDoc.getElementsByTagName('HLight');//try and build arrayvar dData=new array[()]for (i=0; i<nRev.length; i++) { dData[i].push( value: (nRev[i].childNodes[0].nodeValue), color: (nCol[i].childNodes[0].nodeValue), highlight: (nHL[i].childNodes[0].nodeValue), label: (nSubOrg[i].childNodes[0].nodeValue) ); }; Any help would be appreciated. Cheers Soggy
  10. Ustag

    sorting arrays

    Hi, I am generating a bunch of arrays but I would like to change the order of these. This is my code now: $players_killed['time'] = strtotime($time);$players_killed['name'] = ': '.$player;arsort($players_killed, SORT_NUMERIC);echo var_dump($players_killed) .'<br>'; And this is the output: array(2) { ["time"]=> int(1334027580) ["name"]=> string(106) ": Brbasher" }array(2) { ["time"]=> int(1334029860) ["name"]=> string(102) ": Dynext" }array(2) { ["time"]=> int(1334029260) ["name"]=> string(110) ": Kronigrass" }array(2) { ["time"]=> int(1334036580) ["name"]=> string(108) ": Poliminia" } How can I make them order by the time value? My attempt with arsort($players_killed, SORT_NUMERIC); sure failed.
×
×
  • Create New...