0

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;
                }
            }
        }
  ....
1
  • 2
    This is an error - not a syntax error, but a coding error. The second function will replace the first, after which there's no way to call the first one. Commented Mar 5, 2014 at 11:24

1 Answer 1

3

Only the second function will be called - the first one will be overridden.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.