Jump to content

How-to change an id with {if} when input box is checked ?


Recommended Posts

Hello,

 

I need to change the id of the quantity input in my product.tpl when the radio input is checked.

 

WHY?

 

post-791610-0-74960600-1413972336_thumb.png

 

My product.tpl display a "Add to cart" for each attribute.

When I select for instance the second attribute and choose "1" quantity or any quantity it adds the quantity in the first quantity box (here in the example "5")

--> Only the first quantity box works, the others don't.

 

So, I think I've managed to see why, it's because all the input quantity have the same id "quantity_wanted",

 

and the script just add the first quantity he finds in any input with id "quantity_wanted"(the first attribute then)

<input id="quantite" type="radio" class="attribute_radio" name="{$groupName}" value="{$id_attribute}" {if ($group.default == $id_attribute)} checked="checked"{/if} onclick="findCombination();
                                                                                                                                    getProductAttribute();" />
<span id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) OR $virtual OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>
<!-- <label>{l s='Quantity:'}</label> -->
<input type="number" name="qty" id="quantity_wanted" class="text" value="1" size="2" maxlength="2" />
</span>

THEN

 

What I need, is something like this with {if} (of course it doesn't work, as I don't know how-to properly write it)

<input type="number" name="qty" {if (input.#quantite.checked == "checked")} id="quantity_wanted"{/if} class="text" value="1" size="2" maxlength="2" />

Could someone tell me how-to write it properly?

Or if you have some other solution to my problem, I'm listening.

 

Best regards,

post-791610-0-74960600-1413972336_thumb.png

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...