Skip to content

Commit

Permalink
add max function
Browse files Browse the repository at this point in the history
  • Loading branch information
sasbcl committed Sep 5, 2012
1 parent 32d7b92 commit d003b91
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions calc.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

<script language=javascript type="text/javascript">

var plus,minus,divide,multiply
var plus,minus,divide,multiply,max

function initialize(){
plus=document.calc.operator.options[0]
minus=document.calc.operator.options[1]
divide=document.calc.operator.options[2]
multiply=document.calc.operator.options[3]
max=document.calc.operator.options[4]
}

function calculate(){
Expand All @@ -23,7 +24,9 @@
if (divide.selected)
document.calc.answer.value = a / b
if (multiply.selected)
document.calc.answer.value = a * b
document.calc.answer.value = a * b
if (max.selected)
document.calc.answer.value = Math.max(a,b)
}

</script>
Expand All @@ -44,12 +47,13 @@ <h2>Calc</h2>
<option value=minus>-
<option value=divide>/
<option value=multiply>*
<option value=max>max
</select>

<input type=text name=val2 size=10>
=
<input type=text name=answer size=10>
<input type=button value=answer onClick="calculate()">
<input type=button value="show answer" onClick="calculate()">
</form>

<br><br>
Expand Down

0 comments on commit d003b91

Please sign in to comment.