复合IF声明它为Javascript,函数不返回值

挖4.0

复合IF声明它为Javascript,函数不返回该值。我找不到语法错误,但是我很确定这是一个简单的错误。这在课堂上用作示例,并在那里运行,我受命进行一些修改,但现在无法正常运行。

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Credit Card Payment</title>
<script type="text/javascript">
function calcPay(paybill)
{
  yourPay = 0;
  if (paybill.paytype[0].checked == true)
  {
    yourPay = (yourPay + 50);
  }
  else
  {
    yourPay = (yourPay + 0);
  }
}
if (paybill.medtype[0].checked == true)
{
  yourPay = (yourPay + (bal.value * .10));
}
else
{
  if (paybill.medtype[1].checked == true)
  {
    yourPay = yourPay + bal.value;
  }
  else
  {
    yourPay = yourPay + otherP.value;
  }
}
yourPay = Math.round(yourPay*100)/100;
return yourPay;
}
</script>
</head>
<body>
<h1>Calc Pay</h1>
<form name="paybill">
<p>Enter name:
<input type = "text" name="payname"></p>
Credit Card Number: 
<input type = "text" name="cardNo"></p>
<p>Account Balance: <input type = "text" name="bal">
<p>Enter type:<br />

<input type = "radio" name="paytype" value="salary">Late Payment<br />
<input type = "radio" name="paytype" value="hourly">Prior to Due Date</p>
</p>
<p>Enter Desired Payment Type:<br />
<input type = "radio" name="medtype">Minimum Payment<br />
<input type = "radio" name="medtype">Pay Balance<br />
<input type = "radio" name="medtype">Other Amount: <input type = "text" 

name="otherP"></p>

<input type="button" value="Calculate your payment" onclick="pay.value=calcPay

(paybill)" />
<b><i>Your payment is:</i></b> <input type="text" name="pay" size="10" /><be />

</form>
</body>
</html>
安吉特·拉娜(Ankit Rana)
    <script type="text/javascript">
        function calcPay(paybill)
        {
             var yourPay = 0; // first declare yourPay.

            if (!!paybill.paytype[0].checked)
            {
                yourPay = (yourPay + 50);
            }


        if (!!paybill.medtype[0].checked)
        {
            yourPay = (yourPay + (paybill.bal.value * .10)); //bill is part of paybill
        }
        else
        {
            if (!!paybill.medtype[1].checked)
            {
                yourPay = yourPay + paybill.bal.value; //bill is part of paybill
            }
            else
            {
                yourPay = yourPay + paybill.otherP.value;//otherP is part of paybill
            }
        }
            yourPay = Math.round(yourPay*100)/100;
            return yourPay;
        }
    </script>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章