#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    56
    Rep Power
    28

    Integer versus strings


    Code:
    $('tr[name=itemrow]').each(function()
    	{
    	var $price = $(this).find('input[name="price[]"]').val();
    	var $item = $(this).attr('which');
    	if(sellvalue[$item] > $price)
    		{
    		$(this).find('b').wrap('<font color="red"/>');
    		}
    	});
    I've figured out that $price is a string, and though you cannot see the declaration of the array sellvalue it's an array of strings too. This means 750 is greater than 10,000.

    How do I make it treat $price and sellvalue[$item] as integers so that 750 is less than 10,000?
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,009
    Rep Power
    2791
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    56
    Rep Power
    28
    Awesome! Thank you Winters!

    All my searches for something like pascal's strtoint were fruitless, I just didn't know what to search for.

IMN logo majestic logo threadwatch logo seochat tools logo