Javascript - Compare value to Associative array index
<p>I have the following code:</p>

<pre><code>var license_price = 0;
    var num_licenses = jQuery('#num_licenses').val();
    var lp = {};

                lp[1]=12.50;
                lp[10]=15.50;
                lp[50]=50.00;

    for(var index in lp) {alert(index);
        if (num_licenses &gt;= index){
            license_price = parseFloat(lp[index]);
        }
    }
    //alert(license_price);
    jQuery('#total_price').val((num_licenses * license_price));
</code></pre>

<p>This code determines the value entered in the num_licenses box, then goes through the array lp and assigns a price based on the value of each key. So, if num_licenses = 8, the price should be 12.50 each, if the num_licess = 60, the price should be $60.</p>

<p>It works for all values except 2 - 9. If I enter 2-9, the price from fp[10] is used. But, if it is 1, then I get 12.50.</p>

<p>take care,
lee</p>
