SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: ?

  1. #1
    SitePoint Member
    Join Date
    Mar 2004
    Location
    gh
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ?

    Hi there,

    What the difference between this bit of code

    if (items.length == 1) items[i].quantity = parent.cart.document.form1.qty.value;

    and this

    if (numitems == 1)
    items[i].quantity = parent.cart.document.form1.qty.value;

    thanks

    edd

  2. #2
    SitePoint Wizard silver trophy rushiku's Avatar
    Join Date
    Dec 2003
    Location
    A van down by the river
    Posts
    2,056
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    items.length is the size of the items array
    ie:
    if( my array has one element )
    then do something

    numitems is a variable
    ie:
    if( my variable has a value of one )
    then do something

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They're both variables (object properties); the first one is set automatically by the system, reflecting the length of an array (presumably); the other is likely set by the script itself. Hard to say what the second one does, wuthout seeing the program logic.
    ::: certified wild guess :::


Bookmarks

Posting Permissions

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