Jquery多个IF语句无法正常工作,可能存在优先级问题?

时间:2017-11-29 15:09:52

标签: jquery

我有这个脚本在提交时检查2个下拉字段,并根据用户的选择将用户发送到3个登录页面中的1个。如果这些字段都不匹配,则会转到此处未列出的第3个默认目标网页。问题是,如果他们选择角色"房地产经纪人/房地产团队负责人/经纪人"无论选择何种贷款,我都希望他们去登陆页面1。但如果他们选择"< 10"或者" 10 - 24",他们去登陆页面-2。我尝试为这些特定情况添加前2个if语句,但它并没有。工作。关于如何选择角色的任何想法"房地产经纪人/房地产团队负责人/经纪人"优先于任何贷款选择选项,并将它们发送到landingpage-1?

谢谢!



<script>
  lp.jQuery(function($) {
    $('#form-1').live('change',function(){
        var selectedLoan = $('#loan').val();
        var selectedRole = $('#role').val();
      
      	if(selectedLoan == "< 10" && selectedRole == "Realtor / Real Estate Team Leader / Broker"){
          window.module.lp.form.data.confirmData = "https://mycompany.com/landingpage-1/";
		}
        if(selectedLoan == "10 - 24" && selectedRole == "Realtor / Real Estate Team Leader / Broker"){
          window.module.lp.form.data.confirmData = "https://mycompany.com/landingpage-1/";
		}
        if(selectedRole == "Realtor / Real Estate Team Leader / Broker"){
          window.module.lp.form.data.confirmData = "https://mycompany.com/landingpage-1/";
        }
        if(selectedLoan == "< 10"){
          window.module.lp.form.data.confirmData = "https://mycompany.com/landingpage-2/";
        }
        if(selectedLoan == "10 - 24"){
          window.module.lp.form.data.confirmData = "https://mycompany.com/landingpage-2/";
        }
        if(selectedRole == "Loan Officer / Originator"){
          window.module.lp.form.data.confirmData = "https://mycompany.com/landingpage-2/";
        }
        if(selectedRole == "Branch Manager"){
          window.module.lp.form.data.confirmData = "https://mycompany.com/landingpage-2/";
        }
        if(selectedRole == "Individual Contributor - Sales"){
          window.module.lp.form.data.confirmData = "https://mycompany.com/landingpage-2/";
        }
        if(selectedRole == "Individual Contributor - Other"){
          window.module.lp.form.data.confirmData = "https://mycompany.com/landingpage-2/";
        }
    });
  });
</script>
&#13;
&#13;
&#13;

0 个答案:

没有答案