Jquery debugging issue
<p>I'm currently working on a wp e-commerce system and I've managed to customized it according to my needs. I'm facing a pretty annoying problem by now. I'm not that familiar with javascript and jquery though I've figured out where the issue might be. I'm struggling finding a solution though.</p>

<p>The problem: Based on a form (select menu) a ajax function is called and the price changes and it does, though not on the correct product. Instead it is changing the last element every time.</p>

<p>Snippet from the jquery function which I think handles this specific aspect</p>

<pre><code>// update the price when the variations are altered.
jQuery(".wpsc_select_variation").live('change', function() {
    jQuery('option[value="0"]', this).attr('disabled', 'disabled');
    parent_form = jQuery(this).parents("form.product_form");
    if ( parent_form.length == 0 )
        return;     
    form_values =jQuery("input[name='product_id'], .wpsc_select_variation",parent_form).serialize( );
    jQuery.post( 'index.php?update_product_price=true', form_values, function(response) {
        var stock_display = jQuery('div#stock_display_' + product_id),
            price_field = jQuery('#product_price_' + product_id),
            price_span = jQuery('#product_price_' + product_id),
            donation_price = jQuery('input#donation_price_' + product_id),
            old_price = jQuery('#old_product_price_' + product_id),
            save = jQuery('#yousave_' + product_id),
            buynow = jQuery('#BB_BuyButtonForm' + product_id);
        if ( response.variation_found ) {
            if ( response.stock_available ) {
                stock_display.removeClass('out_of_stock').addClass('in_stock');
            } else {
                stock_display.addClass('out_of_stock').removeClass('in_stock');
            }
        }

        stock_display.html(response.variation_msg);

        if ( response.price !== undefined ) {
            if (price_field.length &amp;&amp; price_field.attr('type') == 'text') {
                price_field.val(response.numeric_price);
            } else {
                price_span.html(response.price);
                old_price.html(response.old_price);
                save.html(response.you_save);
            }
            donation_price.val(response.numeric_price);
        }
    }, 'json');
});
</code></pre>

<p>And a snippet of the matching html which displays the prices.</p>

<pre><code>&lt;p class="pricedisplay &lt;?php echo wpsc_the_product_id(); ?&gt;" id=""&gt;
                            &lt;!--&lt;?php // _e('Price', 'wpsc'); ?&gt;:--&gt;
                                &lt;span id="product_price_&lt;?php echo wpsc_the_product_id(); ?&gt;" class="currentprice pricedisplay"&gt;
                                    &lt;?php echo wpsc_the_product_price(); ?&gt;
                                &lt;/span&gt;
&lt;/p&gt;
</code></pre>

<p>I think it might be due to the jquery selecting the last element instead of a specific id.</p>

<p>I thank you very much in advance for your help. It is appreciated.</p>

<p>/nickifrandsen                      </p>
