my calculator work perfect in IE but not in mozilla? what i need to do..
i think its all about to my function i need help to onClick event. pls.
here's code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../css/calculatorCss.css" rel="stylesheet" type="text/css" />
<title>tile calculator</title>
<script type="text/javascript">
<!--variable declaration only-->
tWidth = 0;
tLength = 0;
tUnit1 = 0;
tUnit2 = 0;
tSize = 0;
<!--validation for width can accept numbers and point only-->
function testWidth()
{
var reg=/^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;
var valWidth = form1.width.value;
if(reg.test(valWidth))
{
form1.width.style.backgroundColor = "white";
tWidth = parseFloat(form1.width.value);
}
else
{
form1.width.style.backgroundColor = "red";
}
return false;
}
<!--validation for length can accecpt numbers and point only-->
function testLength()
{
var reg=/^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;
var valLength = document.getElementById("length").value;
if(reg.test(valLength))
{
form1.length.style.backgroundColor = "white";
tLength = parseFloat(form1.length.value);
}
else
{
form1.length.style.backgroundColor = "red";
}
return false;
}
<!--setting for value of tUnit1 and tUnit2-->
function SelectedValue()
{
var index = document.getElementById("select").selectedIndex;
if(index == 0)
{
form1.select.style.backgroundColor = "red";
}
else if (index == 1)
{
tUnit1=10;
tUnit2=10;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 2)
{
tUnit1=10;
tUnit2=29;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 3)
{
tUnit1=10;
tUnit2=30;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 4)
{
tUnit1=10;
tUnit2=33;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 5)
{
tUnit1=13;
tUnit2=50;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 6)
{
tUnit1=15;
tUnit2=15;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 7)
{
tUnit1=15;
tUnit2=30;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 8)
{
tUnit1=20;
tUnit2=20;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 9)
{
tUnit1=20;
tUnit2=25;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 10)
{
tUnit1=20;
tUnit2=30;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 11)
{
tUnit1=25;
tUnit2=33;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 12)
{
tUnit1=30;
tUnit2=30;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 13)
{
tUnit1=30;
tUnit2=45;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 14)
{
tUnit1=30;
tUnit2=60;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 15)
{
tUnit1=40;
tUnit2=40;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 16)
{
tUnit1=50;
tUnit2=12;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 17)
{
tUnit1=50;
tUnit2=50;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 18)
{
tUnit1=58;
tUnit2=20;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 19)
{
tUnit1=5;
tUnit2=20;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 20)
{
tUnit1=5;
tUnit2=29;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 21)
{
tUnit1=5;
tUnit2=30;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 22)
{
tUnit1=60;
tUnit2=60;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 23)
{
tUnit1=60;
tUnit2=90;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 24)
{
tUnit1=6;
tUnit2=30;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 25)
{
tUnit1=7;
tUnit2=20;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 26)
{
tUnit1=7;
tUnit2=30;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 27)
{
tUnit1=80;
tUnit2=80;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 28)
{
tUnit1=8;
tUnit2=29;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 29)
{
tUnit1=8;
tUnit2=30;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 30)
{
tUnit1=8;
tUnit2=33;
form1.select.style.backgroundColor = "white";
return false;
}
else if (index == 31)
{
tUnit1=60;
tUnit2=120;
form1.select.style.backgroundColor = "white";
return false;
}
}
<!--computation process-->
function compute(form)
{
if((form1.width.value !="" ) || (form1.length.value != "") || (document.getElementById("nameofselectiongroup").value!=0))
{
if(form1.cm.cm_0.checked)
{
tSize=100;
}
else if(form1.cm.cm_1.checked)
{
tSize=2.45;
}
else if(form1.cm.cm_2.checked)
{
tSize=30.48;
}
else
{
tSize=0;
alert('no unit');
}
a = (tSize*tWidth)/tUnit1;
b = (tSize*tLength)/tUnit2;
ans = a*b;
elem = document.getElementById("ans");
elem.value = ans;
}
else
{
alert('input width or length or tile size');
}
}
<!--Reset only-->
function resetButton()
{
tWidth = 0;
tLength = 0;
tUnit1 = 0;
tUnit2 = 0;
tSize = 0;
}
//if (form.cm.cm_0.checked)((10000/((width/tileWidth)*(length/tileLength)))
//else if (form.cm.cm_1.checked)(1550.0031/((width/tileWidth)*(length/tileLength)))
//else if (form.cm.cm_2.checked)(10.7639104/((width/tileWidth)*(length/tileLength)))
//else{
// alert("please select unit");
//}
<!--for display only-->
//{
//var selectValue = document.getElementById("select").value;
//a = selectValue;
//elem = document.getElementById("a");
//elem.value = a;
</script>
</head>
<body>
<div id="calBackground">
<div id="formHolder">
<form id="form1" name="form1" method="post" action="">
<table width="216" height="199" border="0">
<tr>
<td width="210" height="24"><input name="width" type="text" id="width" onblur="testWidth(width);" size="15"/></td>
</tr>
<tr>
<td height="24"><input name="length" type="text" id="length" onblur="testLength();" size="15"/></td>
</tr>
<tr>
<td height="32"><label>
<input type="radio" name="cm" value="radio" id="cm_0"/>
</label>
<label>
<input type="radio" name="cm" value="radio" id="cm_1" />
</label>
<label>
<input type="radio" name="cm" value="radio" id="cm_2" />
</label></td>
</tr>
<tr>
<td height="48"><select name="select" id="select" onchange="SelectedValue();">
<option value=" "></option>
<option value="10x10">10x10</option>
<option value="10x29">10x29</option>
<option value="10x30">10x30</option>
<option value="10x33">10x33</option>
<option value="13x50">13x50</option>
<option value="15x15">15x15</option>
<option value="15x30">15x30</option>
<option value="20x20">20x20</option>
<option value="20x25">20x25</option>
<option value="20x30">20x30</option>
<option value="25x33">25x33</option>
<option value="30x30">30x30</option>
<option value="30x45">30x45</option>
<option value="30x60">30x60</option>
<option value="40x40">40x40</option>
<option value="50x12">50x12</option>
<option value="50x50">50x50</option>
<option value="58x20">58x20</option>
<option value="5x20">5x20</option>
<option value="5x29">5x29</option>
<option value="5x30">5x30</option>
<option value="60x60">60x60</option>
<option value="60x90">60x90</option>
<option value="6x30">6x30</option>
<option value="7x20">7x20</option>
<option value="7x30">7x30</option>
<option value="80x80">80x80</option>
<option value="8x29">8x29</option>
<option value="8x30">8x30</option>
<option value="8x33">8x33</option>
<option value="60x120">60x120</option>
</select></td>
</tr>
<tr>
<td>
<input type="button" name="button" value="Calculate" onclick="compute(this.form)" return="false"/>
<input type="reset" value="Reset" onclick="resetButton"/></td>
</tr>
<tr>
<td height="31"><input name="ans" type="text" id="ans" size="16" readonly="readonly" /></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>