Reputation: 1848
I'm taking a look at some existing code on our contact form, and it seems one of our JS guys has put two functions with the same name, one after the other. Can anybody advise how/if both these functions might execute?
function check_webtolead_fields(){
if (check_form('WebToLeadForm')) {
alert("form sent");
//document.WebToLeadForm.submit();
return true;
}
return false;
}
function check_webtolead_fields(){
if(document.getElementById('bool_id') != null){
var reqs=document.getElementById('bool_id').value;
bools = reqs.substring(0,reqs.lastIndexOf(';'));
var bool_fields = new Array();
var bool_fields = bools.split(';');
nbr_fields = bool_fields.length;
for(var i=0;i<nbr_fields;i++){
if(document.getElementById(bool_fields[i]).value == 'on'){
document.getElementById(bool_fields[i]).value = 1;
}
else{
document.getElementById(bool_fields[i]).value = 0;
}
}
}
....
Upvotes: 0
Views: 70
Reputation: 958
Only the second function will be called - the first one will be overridden.
Upvotes: 3