Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what does += mean?

Status
Not open for further replies.

echostorm

Vendor
Apr 10, 2005
28
AU
Hey all,

What does the != in the follwing function mean.
Code:
if (item_id != ' ') {


And the += and &on0= and escape in this one?
Code:
 cartUrl += '&on0=' + escape("Size");



Here is the entire function
Code:
function addToCart (qty,item_id,name,price,size,color,shipping,shipping2) {
   var cartUrl = paypal_url 
        + 'add=1'
        + '&business=' + escape(business)
        + '&currency_code=' + escape(currencyCode)
        + '&amount=' + escape(price);
  if (item_id != '') {
    cartUrl += '&item_number=' + escape(item_id);
  }
  if (name != '') {
    cartUrl += '&item_name=' + escape(name);
  }
  if (size != '') {
    cartUrl += '&on0=' + escape("Size");
    cartUrl += '&os0=' + escape(size);
  }
  if (color != '') {
    cartUrl += '&on1=' + escape("Color");
    cartUrl += '&os1=' + escape(color);
  }
  if (qty != '' && qty != 0) {
    cartUrl += '&quantity=' + escape(qty);
    cartUrl += '&undefined_quantity=1';
  }
  if (shipping != '') {
    cartUrl += '&shipping=' + escape(shipping);
  }
  if (shipping2 != '') {
    cartUrl += '&shipping2=' + escape(shipping2);
  }
  openCartWin(cartUrl);
}

If you know one or any of these please reply. Thanks

Echo
 

"!=" means "not equal to". It is the opposite of "==" which means "equal to".

"+=" is simply a shortcut for adding a value onto a variable. So instead of "x = x + y", you can say "x += y". It also works for other operators, too: "-=", "*=" and "/=" all work.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
escape is a javascript function that non alphanumeric characters to character codes....ex space gets converted to %20 and the double quotes (") gets converted to %22 .

'&on0=' is actually a string. In javascript, you can define a string literal by enclosing it in single or doble quotes.

For an excelent, free online javascript tutorial that expects no prior programming knowledge whatsoever, check out Thau's Javascript Tutorial on webmonkey.com

Robert Carpenter
"You and I have need of the strongest spell that can be found to wake us from the evil enchantment of worldliness." - C.S. Lewis (The Weight of Glory)

robert (at) robertcarpenter (dot) net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top