在改变不工作

时间:2015-08-10 09:13:26

标签: javascript php jquery html

在我之前的代码中,我有四种贷款类型   它的所有类型单选按钮

  1. 转化率
  2. FHA
  3. VA
  4. USDA
  5. 我有一个输入字段首付 当我改变四种类型的贷款类型值更改预付款  链接:Site URl

    当我更改此设计界面MY Site url

    在我的设计中有首付价值。旧设计有单笔首付现在我有所有贷款单独首付.i分配功能其显示默认值3.5。如何改变这个?

    <script type="text/javascript">
        var min_jumbo_down_payment_1="<?php echo $min_jumbo_down_payment_1?>";
        var min_jumbo_down_payment_2="<?php echo $min_jumbo_down_payment_2?>";
        var min_fha_down_payment="<?php echo $min_fha_down_payment?>";
        var max_fha_loan="<?php echo $max_fha_loan?>";
        var max_va_loan="<?php echo $max_va_loan?>";
    
    
        function isNumeric(strString)
           //  check for valid numeric strings  
           {
    
           var strValidChars = "0123456789.-";
           var strChar;
           var blnResult = true;
    
           if (strString.length == 0) return false;
    
           //  test strString consists of valid characters listed above
           for (i = 0; i < strString.length && blnResult == true; i++)
              {
              strChar = strString.charAt(i);
              if (strValidChars.indexOf(strChar) == -1)
                 {
                  blnResult = false;
                 }
              }
           return blnResult;
           }
    
        function ficoChanged()
        {
          //setDownPayment();
    
          getMIP("hh");
    
        }
    
        function loanTypeChanged()
        {
    
          setDownPayment();
          getMIP("loantype"); //it must be set to loantype 
         alert(loantype);
        }
    
        //always called by either change in loantype or change in fico 
        function setDownPayment()
        {
    
            if (userChangedDownPaymentPc_==true  || userChangedDownPaymentAmt_==true)
            {
                return;
            }
            //1. get selected loan type
            for (i=0;i<4;i++ )
            {
              if (document.forms['frmCalculator'].elements['loantype'][i].checked==true)
                {
                  var loantype_=document.forms['frmCalculator'].elements.loantype[i].value;
                  break;
                }
            }
    
            if (loantype_=="usda" || loantype_=="va")
            {
                document.forms['frmCalculator'].elements.downpaymentpc.value=0;
            }       
            else if (loantype_=="fha")
            {
                document.forms['frmCalculator'].elements.downpaymentpc.value=min_fha_down_payment;
            }
            else if (loantype_=="jumbo")
            {
                var ficorange_=document.forms['frmCalculator'].elements['ficorange'].value;
                var arr=ficorange_.split("-");
                if(arr[1] >= 720)
                document.forms['frmCalculator'].elements.downpaymentpc.value=min_jumbo_down_payment_1;
                else
                document.forms['frmCalculator'].elements.downpaymentpc.value=min_jumbo_down_payment_2;
            }
        }
    
    
          function purchasePriceAmountChanged(fromuser_)
          {
              getMIP("hh");
              document.forms['frmCalculator'].elements.monthlypayment.value="";
          }
    
          function monthlyPaymentChanged(fromuser_)
          {
    
              document.forms['frmCalculator'].elements.purchaseprice.value="";
              document.forms['frmCalculator'].elements.upfrontmippc.value="";
              document.forms['frmCalculator'].elements.upfrontmipamt.value="";
              document.forms['frmCalculator'].elements.monthlymippc.value="";
              document.forms['frmCalculator'].elements.monthlymipamt.value="";
              document.forms['frmCalculator'].elements.ssmonthlymippc.value="";
              document.forms['frmCalculator'].elements.ssmonthlymipamt.value="";
    
          }
    
          function downPaymentAmountChanged(fromuser_)//true (if user changed  it) or false
          {
              alert("ok");
            if (document.forms['frmCalculator'].elements.downpaymentamt.value!="")
            {
             document.forms['frmCalculator'].elements.downpaymentpc.value="";         
             getMIP("hh");
            }
          }
    
          function downPaymentPcChanged(fromuser_)//true (if user changed  it) or false
          {
    
           alert("ok 1");
            if (document.forms['frmCalculator'].elements.downpaymentpc.value!="")
            {
                 alert("ok 2");
             document.forms['frmCalculator'].elements.downpaymentamt.value="";         
             getMIP("hh");
    
            }
          }
    
         //   todo : CHANGE IT, ITS NOT WORKING ANYMORE
          function getLoanAmount()
          {
            var purchaseprice_=0;
            var downpayment_=0;
            var loanamount_=-1;
            var hasloan=false;
            if(document.forms['frmCalculator'].elements.downpaymentamt.value!="")
              {
                downpayment_=document.forms['frmCalculator'].elements.downpaymentamt.value;
              }
            else
              {
                  hasloan=true;
              }
            if (document.forms['frmCalculator'].elements.purchaseprice.value!="")
              {
                 purchaseprice_=document.forms['frmCalculator'].elements.purchaseprice.value;
              }
            else
              {
                hasloan=true;
              }
    
           if (hasloan==false)
              {
                loanamount_= purchaseprice_ - downpayment_ ;
              }
    
              return loanamount_;
          }
    
    
          function getPurchasePrice()
          {
             if (document.forms['frmCalculator'].elements.purchaseprice.value!="")
              {
                 purchaseprice_=document.forms['frmCalculator'].elements.purchaseprice.value;
              }
              else
              {
                 purchaseprice_=-1;
              }
            return purchaseprice_;
          }
    
          function upfrontMIPPcChanged(fromuser_)//true (if user changed  it) else false
          {
    
              alert("ok");
            userChangedUpfrontMIP=fromuser_;
            if (document.forms['frmCalculator'].elements.upfrontmippc.value !="")
              {
               document.forms['frmCalculator'].elements.upfrontmipamt.value="";
              }
          }
    
          function upfrontMIPAmountChanged(fromuser_)//true (if user changed  it) or false
          {
             userChangedUpfrontMIP=fromuser_;
             if (document.forms['frmCalculator'].elements.upfrontmipamt.value !="")
              {
               document.forms['frmCalculator'].elements.upfrontmippc.value="";
              }
          }
    
          function monthlyMIPPcChanged(fromuser_)//true (if user changed  it) else false
          {
             userChangedMonthlyMIP=fromuser_;
             if (document.forms['frmCalculator'].elements.monthlymippc.value !="")
              {
               document.forms['frmCalculator'].elements.monthlymipamt.value="";
              }
          }
    
          function monthlyMIPAmountChanged(fromuser_)//true (if user changed  it) or false
          {
             userChangedMonthlyMIP=fromuser_;
             if (document.forms['frmCalculator'].elements.monthlymipamt.value !="")
              {
               document.forms['frmCalculator'].elements.monthlymippc.value="";
              }
          }
    
          function ssmonthlyMIPPcChanged(fromuser_)//true (if user changed  it) else false
          {
             userChangedSSMonthlyMIP=fromuser_;
             if (document.forms['frmCalculator'].elements.ssmonthlymippc.value !="")
              {
               document.forms['frmCalculator'].elements.ssmonthlymipamt.value="";
              }
          }
    
          function ssmonthlyMIPAmountChanged(fromuser_)//true (if user changed  it) or false
          {
             userChangedSSMonthlyMIP=fromuser_;
             if (document.forms['frmCalculator'].elements.ssmonthlymipamt.value !="")
              {
               document.forms['frmCalculator'].elements.ssmonthlymippc.value="";
              }
          }
    
         function propertyTaxPcChanged(fromuser_)//true (if user changed  it) or false
          {
            if (document.forms['frmCalculator'].elements.propertytaxpc.value!="")
            {
             document.forms['frmCalculator'].elements.propertytaxamt.value="";
            }
          }
    
    
         function propertyTaxAmountChanged(fromuser_)//true (if user changed  it) or false
          { 
            if (document.forms['frmCalculator'].elements.propertytaxamt.value!="")
            {
             document.forms['frmCalculator'].elements.propertytaxpc.value="";
            }
          }
    
         function hazardInsurancePcChanged(fromuser_)//true (if user changed  it) or false
          {
            if (document.forms['frmCalculator'].elements.hazardinsurancepc.value!="")
            {
             document.forms['frmCalculator'].elements.hazardinsuranceamt.value="";
            }
          }
    
         function hazardInsuranceAmountChanged(fromuser_)//true (if user changed  it) or false
          { 
            if (document.forms['frmCalculator'].elements.hazardinsuranceamt.value!="")
            {
             document.forms['frmCalculator'].elements.hazardinsurancepc.value="";
            }
          }
    
         function melloRoosAmountChanged(fromuser_)//true (if user changed  it) or false
          { 
            if (document.forms['frmCalculator'].elements.melloroosfeeamt.value!="")
            {
             document.forms['frmCalculator'].elements.melloroosfeepc.value="";
            }
          }  
    
         function melloRoosPcChanged(fromuser_)//true (if user changed  it) or false
          { 
            if (document.forms['frmCalculator'].elements.melloroosfeepc.value!="")
            {
             document.forms['frmCalculator'].elements.melloroosfeeamt.value="";
            }
          }     
    
         function other1PcChanged(fromuser_)//true (if user changed  it) or false
          { 
            if (document.forms['frmCalculator'].elements.other1pc.value!="")
            {
             document.forms['frmCalculator'].elements.other1amt.value="";
            }
          } 
    
         function other1AmountChanged(fromuser_)//true (if user changed  it) or false
          { 
            if (document.forms['frmCalculator'].elements.other1amt.value!="")
            {
             document.forms['frmCalculator'].elements.other1pc.value="";
            }
          }       
    
         function other2PcChanged(fromuser_)//true (if user changed  it) or false
          { 
            if (document.forms['frmCalculator'].elements.other2pc.value!="")
            {
             document.forms['frmCalculator'].elements.other2amt.value="";
            }
          } 
    
         function other2AmountChanged(fromuser_)//true (if user changed  it) or false
          { 
            if (document.forms['frmCalculator'].elements.other2amt.value!="")
            {
             document.forms['frmCalculator'].elements.other2pc.value="";
            }
          }
    
         function other3PcChanged(fromuser_)//true (if user changed  it) or false
          { 
            if (document.forms['frmCalculator'].elements.other3pc.value!="")
            {
             document.forms['frmCalculator'].elements.other3amt.value="";
            }
          } 
    
         function other3AmountChanged(fromuser_)//true (if user changed  it) or false
          { 
            if (document.forms['frmCalculator'].elements.other3amt.value!="")
            {
             document.forms['frmCalculator'].elements.other3pc.value="";
            }
          }
    
          function secondsChanged()
          {
            getMIP("hh");
          }
    

    我有预付款代码看起来像新设计

    <div class="col-md-2 padding-Zero" >
    <input name="downpaymentpc" id="downpaymentpc" type="text" class="txt" size="8"  maxlength="8" onChange="javascript:downPaymentPcChanged(true);" value="<?php echo $min_fha_down_payment;?>" />
     </div>
    

    此代码在新设计中分配四个贷款支付首付款字段..  但是所有输入字段都显示默认值3.5 ..

    我的旧设计代码首期付款

         <td>Down payment $</td>
         <td> <input name="downpaymentpc" id="downpaymentpc" type="text" size="8" maxlength="8" onChange="javascript:downPaymentPcChanged(true);" value="<?php echo $min_fha_down_payment;?>" />%</td>
         <td colspan="2">Or $ <input name="downpaymentamt" id="downpaymentamt" type="text" size="8" maxlength="8" onChange="javascript:downPaymentAmountChanged(true);"  />   </td>
      </tr>
    

    在我的旧设计中工作得很好。相同功能不工作新设计?对此有何想法?

0 个答案:

没有答案