Find Max Value

[Total: 0    Average: 0/5]

This shows how to findthe max value out of 3 text boxes.

Head Code:

function bignum(_form) 
 var _numa   = parseInt(_form.numa.value); 
 var _numb   = parseInt(_form.numb.value); 
 var _numc   = parseInt(_form.numc.value); 
 var _maxnum; 

     <-Greater --- Lower->
 Case 1: A B C
 Case 2: A C B
 Case 3: B A C
 Case 4: B C A
 Case 5: C A B
 Case 6: C B A
 if (_numa > _numb)
   if (_numa > _numc)
     _maxnum=_numa; /* Case 1,2 */
	 _maxnum=_numc; /* Case 5 */
   if (_numb > _numc)
	 _maxnum=_numb; /* Case 3,4 */
	 _maxnum=_numc; /* Case 6 */
 return false;


Body Code:

<center><h1>IST 240 Homework Part 2</h1><hr width=600></center> 

A. Input 3 numbers in the correctly marked boxes below, then click Submit to find their maximum.<br> 
<form name="myform" onsubmit="return bignum(this);"> 

   Number: <input type="text" name="numa" size=3><br><br> 
   Number: <input type="text" name="numb" size=3><br><br> 
   Number: <input type="text" name="numc" size=3><br><br> 
<INPUT TYPE="text" name="maxnum" value="?"> 
   <input type="submit" value="Submit"> <!--Submits numbers to function bignum()--> 


Times Viewed: 3

Leave a Reply

Your email address will not be published. Required fields are marked *