Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7782439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:32:41+00:00 2026-06-01T19:32:41+00:00

i make this function : function price(val){ var test = $(‘span.hikashop_product_price_full:visible’).text(); var test2 =

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:32:43+00:00Added an answer on June 1, 2026 at 7:32 pm

    change

    <select id="custome_vara" name="data[item][custome_vara]" size="1" onchange="price(this.value);">
    

    to

    <select id="custome_vara" name="data[item][custome_vara]" size="1">
    

    then add this:

    $('#custome_vara').one('change',function(){
        price($(this+'option:selected').val());
    });
    

    EDIT: In hopes of making your intent clear I will post some “errors” here:

    First, you are missing markup example of:

    'span.hikashop_product_price_full:visible'
    

    Second:

    eyy = eyy.toFixed(2)
    

    should be:

    eyy = eyy.toFixed(2);
    

    Third:

    '<span class=\"hikashop_product_price hikashop_product_price_0 hikashop_product_price_with_discount\">'
    

    can be written as:

    '<span class="hikashop_product_price hikashop_product_price_0 hikashop_product_price_with_discount">'
    

    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/

    function priceNew(val) {
        var discountedPrice = $('.hikashop_product_price_with_discount');
        var percentOff = $('.hikashop_product_discount');
        var price = discountedPrice.text().split(' ');
        var decimalPrice = price[0].replace(',', '.');
        var eyy = parseFloat(decimalPrice) * val / 100 + parseFloat(decimalPrice);
        eyy = eyy.toFixed(2);
        var newPrice = eyy + ' ' + price[1];
        discountedPrice.text(newPrice);
        percentOff.text('-' + val + '%');
        $('.hikashop_product_price').text(newPrice);
    }
    
    $('#custome_vara').one('change', function() {
        priceNew($(this + 'option:selected').val());
    });
    

    Markup:

    <select id="custome_vara" name="data[item][custome_vara]" size="1">
        <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>
    <div>
    <span class="hikashop_product_price_full" id="hikashop_product_price_full"> 
        <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>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function and I want to make the var category to have
I need to make this function work everywhere, except IE6-7 $(function(){ window.scrollTo(0,300); }) Please
I've looked everywhere for this function and cannot find the header files to make
I want to declare an empty list inside a scheme function. To make this
$('#div1').focus(function () { callAnotherFunction(); $(this).animate({}); } I'm trying to make $(this).animate({}); execute after callAnotherFunction();
I'm trying to make a notification area that will show alerts. return this.each(function() {
I use this pseudo-class to make Ajax request to server: function RequestManager(url, params, success,
I think this is a pretty easy question...How do I make a asp.net function
After loading a PHP template (using jQuery's load function), this simple script won't make
$(#tab1).click(function(){ loadTab(1); $('div.HOMEtabdiv ul.HOMEtabs a').removeClass('selected'); $(this).addClass('selected'); }); Would it be possible to make the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.