|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Javascript Comparison
I have three text boxes
A1 A2 A3 A3 must be equal to the higher of either A1 or A2. How do I go about writing this? |
|
#2
|
||||
|
||||
|
Try this for starters
Code:
<script language="JavaScript">
function compareValues(value1, value2, value3)
{
var maxValue;
if (value1 > value2)
{
maxValue = value1;
}
else
{
maxValue = value2;
}
if (maxValue == value3)
{
alert("Max value equals value3");
}
else
{
alert("Max value doesn't equal value3");
}
}
</script>
value1: <input type="text" name="field1"><br>
value2: <input type="text" name="field2"><br>
value3: <input type="text" name="field3"><br>
<input type="button" name="button" value="Compare" onClick="javascript:compareValues(field1.value, field2.value, field3.value);">
</form>
|
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Javascript Comparison |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|