Hi there I am new to js and need some help..
Hope you can help. I have a form that on drop down picks a product that uses a formula to generate a calculation.
the first one works, but the others do not and even though I choose the other products from the drop down it still uses the code from the first product in the select box:
code below:
can you help me with what I am doing wrong?Code:<script type="text/javascript"> jQuery(document).ready(function($) { //Items $("#input_4_11").on('keyup', do_maths); //time taken $("#input_4_35").on('keyup', do_maths); //Hourly Rate $("#input_4_14").on('keyup', do_maths); function do_maths() { if($.isNumeric($('#input_4_11').val()) && $.isNumeric($('#input_4_35').val()) && $.isNumeric($('#input_4_14').val())) { if($(".result-selected").html() !== "Select...") { if($(".result-selected").html("Printing drawing")) { //(RTV Xporter, Xporter PRO and Drawing Manager) = .25 costs1 = 0.25; product_cost1 = 49; var qty = $("#input_4_11").val(); var hourly = $("#input_4_14").val(); var time_taken = $("#input_4_35").val(); var time_saved = ((qty * time_taken) - ((qty * time_taken) * costs1))/60; var money_saved = time_saved * hourly; money_saved = money_saved.toFixed(2); $('#input_4_20').val(time_saved); //Money Saved--------------------------------------------------------------- //(Time Saved / 60) * Hourly Rate $('#input_4_22').val(money_saved); //RTV Product Cost---------------------------------------------------------- $('#input_4_24').val(product_cost1 - 5); //Automatic ROI------------------------------------------------------------ $('#input_4_23').val(money_saved - product_cost1); } else if($(".result-selected").html("Creating digital files")) { //(RTV Xporter, Xporter PRO and Drawing Manager) = .25 costs = 0.25; product_cost = 9.99 + 49 + 255; var qty = $("#input_4_11").val(); var hourly = $("#input_4_14").val(); var time_taken = $("#input_4_35").val(); var time_saved = ((qty * time_taken) - ((qty * time_taken) * costs))/60; var money_saved = time_saved * hourly; money_saved = money_saved.toFixed(2); $('#input_4_20').val(time_saved); //Money Saved--------------------------------------------------------------- //(Time Saved / 60) * Hourly Rate $('#input_4_22').val(money_saved); //RTV Product Cost---------------------------------------------------------- $('#input_4_24').val(product_cost); //Automatic ROI------------------------------------------------------------ $('#input_4_23').val(money_saved - product_cost); } else if($(".result-selected").html("Combined printing and creating digital files")) { //(RTV Xporter, Xporter PRO and Drawing Manager) = .5 // costs = 0.5; //product_cost = 9.99 + 49 + 255; } else if($(".result-selected").html("Update title blocks / drawing sheets")) { //(RTV Drawing Manager) = .1 //costs = 0.1; // product_cost = 255; } else if($(".result-selected").html("Adding and updating revisions on title blocks / drawing sheets")) { //(RTV Drawing Manager) = .35 //costs = 0.35; //product_cost = 255; } else if($(".result-selected").html("Issue and create documentation transmittal for drawings")) { //(RTV Drawing Manager) = .5 //costs = 0.5; // product_cost = 255; } else if($(".result-selected").html("Create and publish digital files to an FTP site")) { //(Xporter Pro) = .5 //costs = 0.5; //product_cost = 49; } else if($(".result-selected").html("Create and update shared parameters ")) { //(RTV Shared Parameter Manager) = .15 //costs = 0.15; // product_cost = 99.50; } else if($(".result-selected").html("Search and create manufactures specific paint materials")) { //(RTV Paint) = .1 // costs = 0.1; // product_cost = 9.99; } else if($(".result-selected").html("Create furniture and fittings schedules")) { //(RTV Reporter) = .65 //var costs = 0.65; //var product_cost = 75; var qty = $("#input_4_11").val(); var hourly = $("#input_4_14").val(); var time_taken = $("#input_4_35").val(); var time_saved = ((qty * time_taken) - ((qty * time_taken) * costs))/60; var money_saved = time_saved * hourly; money_saved = money_saved.toFixed(2); $('#input_4_20').val(time_saved); //Money Saved--------------------------------------------------------------- //(Time Saved / 60) * Hourly Rate $('#input_4_22').val(money_saved); //RTV Product Cost---------------------------------------------------------- $('#input_4_24').val(product_cost); //Automatic ROI------------------------------------------------------------ $('#input_4_23').val(money_saved - product_cost); } //Time Saved----------------------------------------------------------------- /* ((Number of items to Automate *Time taken )* Hourly Rate/60 - (Number of items to Automate * Field 1 (these values are below again)) */ } else { alert("Please go to the top of the page and select a package."); } } else { //Failed } } }); </script>
thank you in advance..


Reply With Quote
Bookmarks