Hi,
I need to write a javascript which will calculate the difference between the 2 rates: Current Rate and the Previous Rate. The difference should not be greater than .20. Say for example if the Previous rate was 4.5 and the Current rate user enters 5.5, It should give a message “Difference greater than 20 bps”, You want to continue.
The rows in the table are randomly generated, some time there will be only one row sometime there will be more than 1
Please see HTML code below
Thanks
Ali
<html>
<head>
<title>Form Validation</title>
</head>
<body>
<script language=”JavaScript” type=”text/javascript”>
function saveRates(){
//Check the rate difference between 2 rates. If the rate difference is greater than .20, confirmation message will be displayed: “Difference greater than 20 bps”
//You want to continue
alert(“Save Rate”)
}
</script>
<BR>
<BR>
<table border=”1″ width=”100%”>
<TR>
<TD>
</TD>
<TD>
Current Rate
Previous Rate
</TD>
</TR>
<TR>
<TD>
<font face=”Arial” size=”2″>
<small>Month1</small>
</font>
</TD>
<TD>
<font face=”Arial” size=”2″>
<small>
<input name=”CurrentMonth1″ size=”15″ type=”text” value=””/>
</small>
</font>
<font face=”Arial” size=”2″>
<small>
<input name=”PreviousMonth1″ size=”5″ type=”text” value=””/>
</small>
</font>
</TD>
</TR>
<TR>
<TD>
<font face=”Arial” size=”2″>
<small>Month2</small>
</font>
</TD>
<TD>
<font face=”Arial” size=”2″>
<small>
<input name=”CurrentMonth2″ size=”15″ type=”text” value=””/>
</small>
</font>
<font face=”Arial” size=”2″>
<small>
<input name=”PreviousMonth2″ size=”5″ type=”text” value=””/>
</small>
</font>
</TD>
</TR>
</tr>
<input LANGUAGE=”JavaScript” type=”button” value=”Save rates” name=”bSaveChanges” ONCLICK=”saveRates();”>
</table>
</body>
</html>