i make this function :
function price(val){
var test = $('span.hikashop_product_price_full:visible').text();
var test2 = test.split('%');
var test3 = test2[1].split(' ');
var test4 = test3[0].replace(',','.');
var eyy = parseFloat(test4) *val/100 + parseFloat(test4);
eyy = eyy.toFixed(2)
var ett = test.replace(test3[0]+' '+test3[1],'<span class=\"hikashop_product_price hikashop_product_price_0 hikashop_product_price_with_discount\">'+eyy+' '+test3[1]+'</span>');
$('span.hikashop_product_price_full:visible').html(ett);
}
i take a value from a dynamic <span> tag (say it is dynamic because it changes depending on other field).
i have a field
<select id="custome_vara" name="data[item][custome_vara]" size="1" onchange="price(this.value);">
<option value="" id="custome_vara_" selected="selected">alb</option>
<option value="20" id="custome_vara_20">stejar auriu</option>
<option value="30" id="custome_vara_30">moreiche</option>
</select>
and it trigger every time i call it. I need to run just once to add % to the initial price.
the span looks like this
<span class="hikashop_product_discount">-10%</span><span class="hikashop_product_price hikashop_product_price_0 hikashop_product_price_with_discount">51,34 €</span> </span>
Question:
When I call the function price() it run the selection on this function and make the selection a int.
How to make the selection static and the field select/option add to this static selection a percent just once per option.
I hope u understood.
Sorry for my english.
Thanks.
change
to
then add this:
EDIT: In hopes of making your intent clear I will post some “errors” here:
First, you are missing markup example of:
Second:
should be:
Third:
can be written as:
I created this fiddle page to help us understand each other: http://jsfiddle.net/2fxxD/
EDIT2:
I think I see what you want. See the following in action here: http://jsfiddle.net/2fxxD/3/
Markup: