I'm making a simple price calculator for where my dad works that calculates prices for some customized mail thing. I am doing it in JS/HTML/CSS because it is for the customer, so they wont have to install anything to run it. Here is the JS code (it uses jQuery):
Firebug says that the variable d is not defined. I have a feeling it's because it's using an each loop. I don't know how to fix this, because i sort of 'borrowed ' some code. Please help quickly, because my dad needs it very soon. If you need my html or xml file, i'd be happy to post it, as long as you don't copy it
Thanks, Tominated
Code:
$(function(){
var job
var a = $("#numRecords").val()
var b = $("#mailpackQuantity").val()
var c = $("#simplexImpressions").val()
$('#jobName').change(
function() {
job = $("#jobName").val()
$.ajax({
type: "GET",
url: "jobs/" + job + ".xml",
dataType: "xml",
success: function(xml) {
$(xml).find('hours').each(function(){
var d = $(this).attr('value')
});
$(xml).find('programming').each(function(){
var e = $(this).attr('cost')
});
$(xml).find('processing').each(function(){
var f = $(this).attr('cost')
});
$(xml).find('printing').each(function(){
var g = $(this).attr('cost')
});
$(xml).find('inserting').each(function(){
var h = $(this).attr('cost')
});
$(xml).find('lodgement').each(function(){
var i = $(this).attr('cost')
});
}
});
var result = ( parseInt(d) * parseInt(e) ) + ( parseInt(a) * parseInt(f) / 1000 ) + ( parseInt(c) * parseInt(g) / 1000 ) + ( parseInt(b) * parseInt(h) / 1000 ) + parseInt(i)
$('#result').text( result );
});
});
Firebug says that the variable d is not defined. I have a feeling it's because it's using an each loop. I don't know how to fix this, because i sort of 'borrowed ' some code. Please help quickly, because my dad needs it very soon. If you need my html or xml file, i'd be happy to post it, as long as you don't copy it
Thanks, Tominated