当我在表单中输入值时,转换器没有显示答案。它会显示弹出警告“你必须输入一个32到40之间的数字”〜谢谢
<HTML>
<HEAD>
<TITLE>Bra Size to Chest Size Converter - CM</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function CalculateSum(Atext, Btext, form)
{
var A = BratoNum(Btext);
var B = parseFloat(CuptoNum(Btext));
form.Answer.value = A + B;
}
function ClearForm(form)
{
form.input_A.value = "";
form.input_B.value = "";
form.Answer.value = "";
}
function BratoNum(str)
{
switch(str.toUpperCase()) {
case "32": return 70;
case "34": return 75;
case "36": return 80;
case "38": return 85;
case "40": return 90;
default: alert('You must enter a number between 32 and 40!');
return 'X';
}
}
function CuptoNum(str)
{
switch(str.toUpperCase()) {
case "A": return 4;
case "B": return 5;
case "C": return 6;
case "D": return 7;
case "E": return 8;
case "F": return 9;
default: alert('You must enter a letter between A and F!');
return 'X';
}
}
// end of JavaScript functions -->
</SCRIPT>
</HEAD>
<BODY>
<P><FONT SIZE="+2">Bra Size to Chest Size Converter</FONT></P>
<FORM NAME="Calculator" METHOD="post">
<P>Enter Bra Size: <INPUT TYPE=TEXT NAME="input_A" SIZE=8></P>
<P>Enter Cup Size: <INPUT TYPE=TEXT NAME="input_B" SIZE=8></P>
<P><INPUT TYPE="button" VALUE="Get Chest Size" name="AddButton" onClick="CalculateSum(this.form.input_A.value, this.form.input_B.value, this.form)"></P>
<P>Your Chest Size is <INPUT TYPE=TEXT NAME="Answer" SIZE=8> inch</P>
<P><INPUT TYPE="button" VALUE="Clear" name="ClearButton" onClick="ClearForm(this.form)"></P>
</FORM>
</BODY>
</HTML>
答案 0 :(得分:1)
var A = BratoNum(Atext);
您正在传递Btext
!
答案 1 :(得分:1)
其实你传递的是无效的 BratoNum函数的参数。那是 为什么它总是进入默认情况'
var A = BratoNum(Atext);
// Here I have changed the argument , which you suppose to pass.