...

View Full Version : what does += mean?



Echostorm
04-12-2005, 12:00 AM
Hey all,

What does the != in the follwing function mean.

if (item_id != ' ') {


And the += and &on0= and escape in this one?

cartUrl += '&on0=' + escape("Size");



Here is the entire function


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

liorean
04-12-2005, 12:24 AM
expr1 != expr2 means "if expr1 is not equal to expr2 return true, otherwise return false".

id += expr is equal to id = id + expr and means "assign id the value of adding id and expr together"


'&on0=' is a simple string, nothing strange with that.


escape is a function that escapes characters that have special meaning in URLs to '%nn' sequences.

sage45
04-12-2005, 12:26 AM
The '!=' is used to signify 'not equal to'

The '+=' means add whatever is after the equal sign to whatever is in front of the plus sign and assign back the the variable in front of the plus sign.

-sage-

Edited: NOOOOOOOOO!!! Beaten to the punch by liorean... Darn you liorean!!!!!!!! But yeah what he said too... :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum