我有一个用于景观美化公司的简单面积计算器,它只能在 chrome、IE 和 Safari 中使用,但不能在 Firefox 中使用。有人可以告诉我问题可能是什么吗?我想这可能是一个js问题。
这是一个工作页面的链接:http: //tinyurl.com/calc1test1
这是html:
<h4><span>Area Calculator</span></h4>
<div class="boxInfo contactForm">
<div style="display:none"><input type="checkbox" name="CampaignList_64585" checked="checked" value="on" /></div>
<div>
<label>Length:</label>
<input type=text name="square_length" size="3" onChange="get_cubicyards();">
</div>
<div>
<label>Width:</label>
<input type=text name="square_width" size="3" onChange="get_cubicyards();">
</div>
<div>
<label>Depth:</label>
<input type=text name="square_depth" size="3" onChange="get_cubicyards();">
</div>
<div class="calcbutton">
<input id="contactSubmit" class="calcsubmit" type="button" value="Get Amounts" onClick="get_cubicyards();">
</div>
<div>
<label>Cubic Yards:</label>
<input type=text name="square_cuyard" onFocus="calculate_totals();this.blur();">
</div>
这是JS:
<script language="Javascript">
function isValidInput(strString)
{
//String of valid characters
var strValidChars = '0123456789.';
var strChar;
var blnResult = true;
var decimalCount = 0;
if (strString.length == 0) return false;
//Test strString consists of valid characters listed above
for (i = 0; i < strString.length && blnResult == true; i++)
{ strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1)
{ blnResult = false; }
if (strChar == '.')
{ decimalCount++; }
}
if (decimalCount > 1)
{ blnResult = false; }
return blnResult;
}
function get_cubicyards()
{ var cubicyards;
if( (eval('document.all.square_depth.value')) && (!isValidInput(eval('document.all.square_depth.value'))) )
{ alert('You must enter only numeric values.');
eval('document.all.square_cuyard.value = \'\'');
return false;
}
if( (eval('document.all.square_length.value')) && (!isValidInput(eval('document.all.square_length.value'))) )
{ alert('You must enter only numeric values.');
eval('document.all.square_cuyard.value = \'\'');
return false;
}
if( (eval('document.all.square_width.value')) && (!isValidInput(eval('document.all.square_width.value'))) )
{ alert('You must enter only numeric values.');
eval('document.all.square_cuyard.value = \'\'');
return false;
}
//Only make calculations if there are valid values specified for ALL necessary fields
if ( (eval('document.all.square_depth.value')) && (eval('document.all.square_length.value')) && (eval('document.all.square_width.value')) )
{ cubicyards = (eval('(document.all.square_depth.value * document.all.square_length.value * document.all.square_width.value)/324')*1000)/1000;
eval('document.all.square_cuyard.value = '+cubicyards);
return true;
}
}
</script>