javascript - Update page section after dropdown selection multiple times -
i have select dropdown menu shipping options. i'd target id update after shipping option selected many times user changes options. option update once.
variable tags using {} expressionengine, i'm not sure situation particular ee.
code follows:
html:
<tr> <th> <span>shipping:</span> <select name="shipping_method" id="shipping_method"> <option value="">select shipping method...</option> {shipping_method_options} </select> </th> <th id="js-shipping-price"> {order_shipping} </th> </tr>
js:
$('#shipping_method').change(function() { var url = $(this.form).attr('action'); var data = $(this.form).serialize(); $.post(url, data, function() { $('#js-shipping-price').load('/global/shipping-price'); }); return false; });
as i'm not well-versed in jquery, above code from: how implement ajax “add cart” expresso store?
tried removing return: false;
since i'm not sure it's needed in case (i'm not sure though), same results.
edit:
/global/shipping-price
ee variable tag used return shipping value of option selected:
{exp:store:checkout}{order_shipping}{/exp:store:checkout}
try using event delegation make sure new data being used:
$(document).on('change', '#shipping_method', function() { ... });
Comments
Post a Comment