activate options-selectbox by jQuery

  • Posts: 68
  • Thank you received: 2
10 years 4 months ago #163229

-- url of the page with the problem -- : mywebsite.com/mypage
-- HikaShop version -- : latest
-- Joomla version -- : latest
-- PHP version -- : 5.4
-- Browser(s) name and version -- : XXXXX x.x.x
-- Error-message(debug-mod must be tuned on) -- :NA

Hi,

I'm building a custom product-configurator.
Each product contains a select box. When activating the select box the price is re-calculated.
This works fine.

Problem:

I've created a button which should trigger the original select box. I can change the value of the hikashop-original-checkbox, no problem here (see jQuery code below).

Te problem is how to activate (which) js-code(event) in this way that the product-price is re-calculated in cart and onscreen.

I guess something like:
jQuery('#hikashop_product_option_0').val(76).trigger('change'); // set the option-value of select box based on my button-click.

hikashopRefreshOptionPrice(); // recalculate price (this is not working???)

I guess I'm missing some js/php include code?

Hope you can help me with this one.

Thanks in advance

Mark

Please Log in or Create an account to join the conversation.

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
10 years 4 months ago #163242

Hi,

It's the function hikashopChangeOption() that you need to call. The function hikashopRefreshOptionPrice() will only do the display of the new price while the hikashopChangeOption() function does both the recalculation and the display of the new price.

Please Log in or Create an account to join the conversation.

  • Posts: 68
  • Thank you received: 2
10 years 4 months ago #163336

Thanks Nicolas,

I've tried this before but this is not working. I guess this has to do with scoping?
I've included my jQuery-code in a separate js-file in which I call your function (after page loaded).
Do I have to load some specific js-file or functions before I can call them?

Your function is not showing any result.

Hope you can help me further.
Thanks in advance

See below code snippet:

// toggle with / without custom text
jQuery('#hikashop_product_option_0').on('change', function() {
set_text_jn(jQuery(this).val());
jQuery('#hikashop_product_option_0').val(76).trigger('change');
hikashopChangeOption(); // call update option price-function
});

Please Log in or Create an account to join the conversation.

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
10 years 4 months ago #163460

Hi,

I don't see why it wouldn't work unless some of the HTML that the function expect to be there has been removed/altered.
The function is global and can be called from anywhere.

Did you get any error message ?
If you give a link to the page we can have a look at what you did.

Please Log in or Create an account to join the conversation.

  • Posts: 68
  • Thank you received: 2
10 years 4 months ago #163480

Nicolas, you're right, my bad.
I'd forgotten to trigger the change-event.......

It works fine now.

Thanks again.

Mark

Last edit: 10 years 4 months ago by squareweb.

Please Log in or Create an account to join the conversation.

Time to create page: 0.063 seconds
Powered by Kunena Forum