var text = ""; function updatePrice() { var A = 0; $(".optionList select:not(.groupOption) option:selected").each(function() { text = $(this).attr("title"); if (text.indexOf("+") > -1) { A += parseFloat(text.substr(text.indexOf("+") + 1, text.length - 1)) } else { if (text.indexOf("-") > -1) { A -= parseFloat(text.substr(text.indexOf("-") + 1, text.length - 1)) } } var B = (basePrice + A).toFixed(0); var C = ""; if (B > 999) { C = B.toString().substr(0, 1) + "," + B.toString().substr(1, B.length - 1) } else { C = B.toString() } $(".price SPAN").text("£" + C) }) } $(document).ready(function() { updatePrice(); $(".optionList select option").removeAttr("selected"); $(".optionList select").each(function() { $(this).find("option:eq(0)").attr("selected", "selected"); $(this).change(function() { updatePrice() }) }) }); var poName, parName, parValue, poID, counter; function populateOptionList(D, C, B, A) { $.ajax({ type: "POST", url: "/DataService.asmx/populateOptionList", data: '{ "poName":"' + D + '", "parName":"' + C + '", "parValue":"' + B + '", "poID":"' + A + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function(E) { $("#ctl00_cph1_" + D).replaceWith(E.d); $(".optionList select").each(function() { $(this).change(function() { updatePrice() }) }); updatePrice() } }) };