I'm having a minor problem with a calculator script. There's 2 text boxes where you input your 2 numbers, and a drop-box that has either +, -, *, or /.
I can't seem to figure out how to set it up, so I tried this method "what would I do in VB.NET?", "Use the IF..ELSE statement". One problem solved, new problem, no idea how to set up the IF..ELSE statement in java script.
Here's what it looks like for the math part....
<script language="javascript" type="text/javascript">
function multiply()
{
a=Number(document.frmSimpleCalculator.txtValue1.value);
b=Number(document.frmSimpleCalculator.txtValue2.value);
c=a*b;
document.frmSimpleCalculator.txtTotal.value = c;
}
</script>
<script language="javascript" type="text/javascript">
function btnCalculateTotal_Click()
{
if (document.frmSimpleCalculator.ddlOperator.value == 1)
{
a = Number(input.txtValue1);
b = Number(input.txtValue2);
c = a + b;
document.frmSimpleCalculator.txtTotal.value = c;
}
else if (document.frmSimpleCalculator.ddlOperator.value == 2)
{
a=Number(document.frmSimpleCalculator.txtValue1.value);
b=Number(document.frmSimpleCalculator.txtValue2.value);
c=a-b;
document.frmSimpleCalculator.txtTotal.value = c;
}
else
{
alert ("<b>Error</b>");
}
</script>
<script type="text/javascript" language="javascript">
function btnClear_Click( )
{
document.frmSimpleCalculator.txtValue1.value = "0";
document.frmSimpleCalculator.ddlOperator.value = "1";
document.frmSimpleCalculator.txtValue2.value = "0";
document.frmSimpleCalculator.txtTotal.value = "0";
}
</script>
If I have to post the whole script, I will. I should mention that this is related to homework, so please don't give me the answer right off the bat, hints are nice though. I already tried googling this problem for 5 hours and found no answer, so..... yeah. The thing related to homework is the math set-up (input a + input b = answer c) the IF..ELSE is my way of trying to set-up the drop-box list for the operations.
Oh right, I'm using Notepad++ to type this out, if that helps out in anyway.
Edit: Oh yeah, forgot I asked for help on the Flash button....... Oops..... ^^' The button went well, sadly, had to change it around a bit. Sorry for not replying to it, hated that term.