表单结果不会仅在IE上显示

时间:2013-05-31 19:46:44

标签: javascript jquery ajax internet-explorer validation

我们在所有浏览器中获得的结果都很好,除了IE以下example form

表格在IE中看起来很好(说成功提交),但结果永远不会通过。我已经尝试删除代码中的所有表(单独)以查看是否有帮助,但它没有。我对Javascript知之甚少,但我正在努力解决这个问题。有任何想法吗?验证(summation_check_final.js)中的javaScript如下:

function validate_input(value,string){
var error = 0;
var reg = /^[\s\d]*$/
if(!reg.test(value)){
        alert(string + ' has to be blank or a number');
        error = 1;
}
return error;
}

function summation(){
var total = 0;
var automotive = $('input[name=Q28_SGVAL_259_SGVAL_1]').val();
total += Number(automotive);
var printing = $('input[name=Q28_SGVAL_269_SGVAL_1]').val();
total += Number(printing);
var hvac = $('input[name=Q28_SGVAL_260_SGVAL_1]').val();
total += Number(hvac); 
var refrigeration = $('input[name=Q28_SGVAL_270_SGVAL_1]').val();
total += Number(refrigeration);        
var conveyors = $('input[name=Q28_SGVAL_261_SGVAL_1]').val();
total += Number(conveyors);        
var robotics = $('input[name=Q28_SGVAL_271_SGVAL_1]').val();
total += Number(robotics);        
var cranes = $('input[name=Q28_SGVAL_262_SGVAL_1]').val();
total += Number(cranes);        
var rubber = $('input[name=Q28_SGVAL_272_SGVAL_1]').val();
total += Number(rubber);        
var elevators = $('input[name=Q28_SGVAL_263_SGVAL_1]').val();
total += Number(elevators);        
var semiconductor = $('input[name=Q28_SGVAL_273_SGVAL_1]').val();
total += Number(semiconductor);        
var food = $('input[name=Q28_SGVAL_264_SGVAL_1]').val();
total += Number(food);        
var shipbuilding = $('input[name=Q28_SGVAL_274_SGVAL_1]').val();
total += Number(shipbuilding);        
var tools = $('input[name=Q28_SGVAL_265_SGVAL_1]').val();
total += Number(tools);        
var textiles = $('input[name=Q28_SGVAL_275_SGVAL_1]').val();
total += Number(textiles);        
var mining = $('input[name=Q28_SGVAL_266_SGVAL_1]').val();
total += Number(mining);        
var woodworking = $('input[name=Q28_SGVAL_276_SGVAL_1]').val();
total += Number(woodworking);        
var packaging = $('input[name=Q28_SGVAL_267_SGVAL_1]').val();
total += Number(packaging);        
var other = $('input[name=Q28_SGVAL_277_SGVAL_1]').val();
total += Number(other);        
var paper = $('input[name=Q28_SGVAL_268_SGVAL_1]').val();
total += Number(paper);
return total;
}

function update_total(){
 var total = summation()
 var num_str = total.toString();
 $("#total").text(num_str);
 return total;
}

$(document).ready(function(){
$("#btn").click(function(){
    var error = 0;
    var automotive = $('input[name=Q28_SGVAL_259_SGVAL_1]').val();
    var printing = $('input[name=Q28_SGVAL_269_SGVAL_1]').val();
    var hvac = $('input[name=Q28_SGVAL_260_SGVAL_1]').val();
    var refrigeration = $('input[name=Q28_SGVAL_270_SGVAL_1]').val();
    var conveyors = $('input[name=Q28_SGVAL_261_SGVAL_1]').val();
    var robotics = $('input[name=Q28_SGVAL_271_SGVAL_1]').val();
    var cranes = $('input[name=Q28_SGVAL_262_SGVAL_1]').val();
    var rubber = $('input[name=Q28_SGVAL_272_SGVAL_1]').val();
    var elevators = $('input[name=Q28_SGVAL_263_SGVAL_1]').val();
    var semiconductor = $('input[name=Q28_SGVAL_273_SGVAL_1]').val();
    var food = $('input[name=Q28_SGVAL_264_SGVAL_1]').val();
    var shipbuilding = $('input[name=Q28_SGVAL_274_SGVAL_1]').val();
    var tools = $('input[name=Q28_SGVAL_265_SGVAL_1]').val();
    var textiles = $('input[name=Q28_SGVAL_275_SGVAL_1]').val();
    var mining = $('input[name=Q28_SGVAL_266_SGVAL_1]').val();
    var woodworking = $('input[name=Q28_SGVAL_276_SGVAL_1]').val();
    var packaging = $('input[name=Q28_SGVAL_267_SGVAL_1]').val();
    var other = $('input[name=Q28_SGVAL_277_SGVAL_1]').val();
    var paper = $('input[name=Q28_SGVAL_268_SGVAL_1]').val();

    error = validate_input(automotive,'Automotive');
    error = validate_input(printing,'Printing');
    error = validate_input(hvac,'Commercial HVAC');
    error = validate_input(refrigeration,'Refrigeration');
    error = validate_input(conveyors,'Conveyors');
    error = validate_input(robotics,'Robotics:');
    error = validate_input(cranes,'Cranes & Hoist');
    error = validate_input(rubber,'Rubber & Plastics');
    error = validate_input(elevators,'Elevators & Escalators');
    error = validate_input(semiconductor,'Semiconductor');
    error = validate_input(food,'Food, Beverage & Tobacco');
    error = validate_input(shipbuilding,'Shipbuilding & Marine');
    error = validate_input(tools,'Machine Tools');
    error = validate_input(textiles,'Textiles');
    error = validate_input(mining,'Mining');
    error = validate_input(woodworking,'Woodworking');
    error = validate_input(packaging,'Packaging & Labeling');
    error = validate_input(other,'Other Discrete Sectors');
    error = validate_input(paper,'Paper & Paperboard');

    var total = update_total();

    var rf = $('input[name=RF]').val();
    if(rf == ''){
        alert('First Name is a required field');
        error = 8;
    }

    var rl = $('input[name=RL]').val();
    if(rl == ''){
        alert('Last Name is a required field');
        error = 8;
    }

    if (total == 100 && error == 0){         
        $.ajax({
            type: "POST",
            url: "http://www.surveygold.com/cgi-bin/WebSurveyResponseProcess.asp", 
            data: $('#SGWebForm').serialize(),
            success: alert('Submit successful')
        });
    }
    if(total != 100){
        alert('The total of the percentages has to be 100');
    }
});
$('input[name=Q28_SGVAL_259_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_269_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_260_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_270_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_261_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_271_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_262_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_272_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_263_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_273_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_264_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_274_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_265_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_275_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_266_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_276_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_267_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_277_SGVAL_1]').change(function(){update_total();});
$('input[name=Q28_SGVAL_268_SGVAL_1]').change(function(){update_total();});     
});

0 个答案:

没有答案