var $ = jQuery; var baseUrl = 'https:/easytitlesearch.com/articles/wp-content/plugins/easytitlesearch/'; var ajaxUrl = baseUrl + 'ajax/'; var priceTimer = null; function calcPrice(pcSelector) { var nr = jQuery('#field_ph9fvu2').val(); var rush = jQuery('.rushYes:checked').length; var commercial = jQuery('.zoningComm:checked').length; var zips = new Array(); jQuery('.zip').each(function() { if (jQuery(this).val() != '') { zips.push(jQuery(this).val()); } }); jQuery.post(ajaxUrl + 'calcprice.php', {'nr': nr, 'rush': rush, 'commercial': commercial, 'zips': zips}, function(res) { jQuery(pcSelector).html('$' + res); }); } jQuery(document).ready(function() { jQuery(document).on('click', '.addaddrlink', {}, function(e) { var numAddrs = jQuery('.zoningRes').length; jQuery.post(ajaxUrl + 'loadaddrfield.php', {num: (numAddrs+1)}, function(res) { jQuery('#ets_addr_Container').append(res); }); e.stopPropogation(); e.preventDefault(); }); jQuery(document).on('click', '.zoningComm,.zoningRes,.rushYes,.rushNo', {}, function() { calcPrice('#rtPrice'); }); jQuery(document).on('change', '#field_ph9fvu2', {}, function() { calcPrice('#rtPrice'); }); jQuery(document).on('keyup', '.zip', {}, function() { clearTimeout(priceTimer); priceTimer = setTimeout("calcPrice('#rtPrice');", 1000); }); calcPrice('#rtPrice'); });