have not checked your code but have done this
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<script type="text/javascript">
/*<![CDATA[*/
function Cal(frm){
var ABC='';
for (var z0=0;z0<frm['chooseccd'].length;z0++){
if (frm['chooseccd'][z0].checked){
ABC=frm['chooseccd'][z0].value;
}
}
var wip=frm['myWidth'];
wip.value=wip.value.replace(/[^0-9.]/g,''); // only floaing point number
var dip=frm['myDistance'];
dip.value=dip.value.replace(/[^0-9.]/g,''); // only floaing point number
if (wip.value&&dip.value&&ABC){
// input values are strings */ or - calculations automatically change the value type to digits
frm['Fdiff'].value=Math.round( ABC * (dip.value / wip.value) * 10) /10;
}
else {
frm['Fdiff'].value='';
}
}
/*]]>*/
</script></head>
<body>
<form name="lenscalc" method="post">
<table border="3">
<tr>
<td><div align="center">1/4" CCD</div></td>
<td><div align="center">1/3" CCD</div></td>
<td><div align="center">1/2" CCD</div></td> Fdiff chooseccd myWidth myDistance
</tr>
<tr>
<td><div align="center"><input type="radio" name="chooseccd" value="3.6" /></div></td>
<td><div align="center"><input type="radio" name="chooseccd" value="4.8" /></div></td>
<td><div align="center"><input type="radio" name="chooseccd" value="6.4" /></div></td>
</tr>
</table>
<table border="3">
<tr>
<td><div align="center"><strong>Width</strong><br />(of object)</div></td>
<td><div align="center"><strong>Distance</strong><br />(from camera to object)</div></td>
<td><div align="center"><strong>Lens size Required</strong><br /></div></td>
<td><input type="button" onclick="Cal(this.form)" value="Calculate" /></td>
</tr>
<tr>
<td><div align="center"><input type="text" name="myWidth" size="4" /> Metres</div></td>
<td><div align="center"><input type="text" name="myDistance" size="4" /> Metres</div></td>
<td><div align="center"><input type="text" name="Fdiff" value="" size="6" disabled="disabled" /> mm</div></td>
<td><div align="center"><input type="button" value=" Reset " onclick="this.form.reset()" /></div></td>
</tr>
</table>
</form>
</body>
</html>
Bookmarks