Javascript Converter Coding Error ~ Showing Bug

Posted by olivia on Stack Overflow See other posts from Stack Overflow or by olivia
Published on 2010-03-13T10:18:41Z Indexed on 2010/03/13 10:25 UTC
Read the original article Hit count: 267

Filed under:

Please help~!

<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>

© Stack Overflow or respective owner

Related posts about JavaScript