sarfaraz.r1406 Posted February 20, 2015 Share Posted February 20, 2015 Hi, I want to display all the combinations of a product in the product list page. I am able to retrieve the combinations from the Controllers. In product-list.php I am using this code :- {foreach from=$combinations key=k item=comb} {if $product.id_product == $k} <p class="comb_title">{$comb.group_name}</p> <select> {foreach from=$comb item=attr} <option class="comb_product" value="{$attr.id_product_attribute}">{$attr.attribute_name} {l s=':'} {convertPrice price=$attr.price}</option> {/foreach} </select> {/if} {/foreach} And extracting the value of class="comb_product" as var idComb= $(this).parent().parent().parent().parent().find('.comb_product').val(); But whatever value is selected from the drop down, it always take the first value only in the variable idComb. Please help me with this issue. Thanks in advance. Link to comment Share on other sites More sharing options...
fred-vinapresta Posted February 20, 2015 Share Posted February 20, 2015 (edited) Hi, try with: var idComb= $( "select option:selected" ); in the "change" event of the select Edited February 20, 2015 by fred-vinapresta (see edit history) Link to comment Share on other sites More sharing options...
sarfaraz.r1406 Posted February 20, 2015 Author Share Posted February 20, 2015 (edited) Thanks for the quick reply. Can you please tell in detail. I am new to js. These changes I have to do in js file or tpl file? I searched a bit on google and tried this code. $(this).parent().parent().parent().parent().find('.comb_product').change(function() { $( "select option:selected" ).each(function() { var idComb= $(this).val(); }); }); But this also does not work. Edited February 20, 2015 by sarfaraz.r1406 (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now