Home Forums Front-end Issues Javascript – update text field


Javascript – update text field

  • Hey –

    I set a JS in order to let the user choose Tour price per 2 selectors (Hotel level (3 options) + Bedrooms quantity (3 options)) – each option have a different price.
    I created a field group with 9 fields (so the admin can update each option price per tour) and add another field to hold the final price (which I need to hide in the ADMIN EDITOR).

    The code display the final price per user select.

    I managed to save the final price with q cookie (which later I load when user direct to the cart), but I rather do it with ACF and I cant find the way to update the field in JS.

    I tried:

    jQuery(‘[data-key=”field_5937f50dd6b18″] input’).val(new_price);

    field_5937f50dd6b18 – filed key which I want to update.
    new_price – the final tour price which I want to update.

    it works only once and I guess I need to add the Tour ID to the request..
    something similar to function update_field($field,$id)

    So my question is: What is the right way to update a ACF filed in JS?

    Thanks in advanced!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.