www.webdeveloper.com
Results 1 to 6 of 6

Thread: rookie to js, cant get a variable working

  1. #1
    Join Date
    Sep 2009
    Location
    oxfordshire, england
    Posts
    210

    rookie to js, cant get a variable working

    hi,

    new to the forum, I am trying to get an alert to show all of the items defined by "G_items" I am using this code

    when I do
    Code:
    alert(G_items);
    it works fine, but when I add a variable saying
    Code:
    var id = g_items;
    then in the alert say
    Code:
    alert(id);
    it just gives me undefined :S can anyone help

    Simon

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    What is G_items and g_items? They are different variables.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Sep 2009
    Location
    oxfordshire, england
    Posts
    210
    the first G_items was a type because I didnt copy the code just typed it in they are both without capitals in the actual code. and they are objects

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    What is g_items?
    At least 98% of internet users' DNA is identical to that of chimpanzees

  5. #5
    Join Date
    Dec 2008
    Posts
    488
    There is nothing wrong with setting one variable to another. Your problem most likely lies in setting g_items. Can you provide us with the entire JS file? Also, please remember that copying/pasting code is the best way to do post here, because your error could rely in spelling or syntax, which might be an error you might not make typing it directly here. (in other words, you might not make the same error twice)
    Last edited by jamesbcox1980; 11-13-2009 at 06:01 PM.

  6. #6
    Join Date
    Nov 2009
    Posts
    9

    Alert JavaScript Array

    From what I'm understanding form your message is that your looking to have a JavaScript Array and then have all the array items displayed as an alert? If this is what you are looking for, I just wrote an article on my website with details:

    http://chadscode.com/index.php/Alert_JavaScript_Array

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles