<script language="javascript">
function add()
{
var divTag = document.createElement("div");
divTag.id = "div";
//alert(divTag.id);
//divTag.setAttribute("align","center");
//divTag.style.margin = "0px auto";
var j=1;
divTag.className ="dynamicDiv";
var v1 =document.getElementById('ttlBoxes').value;
var v2 =document.getElementById('boxno').value;
var d1=parseInt(document.getElementById('ttlBoxes').value);
var d2=parseInt(document.getElementById('boxno').value);
if(v1!=""&& v2!="")
{
if(d2<d1)
{
divTag.innerHTML ='<br /><table width="101%" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable" ><tr ><td width="150" class="label" ><select id="boxtype" name="boxtype+j" ><option value="select">Select</option><option value="Amb">Amb</option><option value="Frz">Frz</option><option value="Ref">Ref</option><option value="Gen">Gen</option></select> <select id="box" name="box"><option value="select" >Select</option><option value="OurBox">Our Box</option><option value="DrBox">Dr.Box</option><option value="Other">Other</option></select>GrossWeight<input type="text" name="grWeight" id="grWeight" value="0" onclick="calc(this)" readonly="readonly" /></td><td width="150" class="label" ><p>Box Nos.<input name="boxno" type="text" class="box" id="boxno" size="20" maxlength="255" value="" /></p><p>ChargebleWeight<input type="text" name="crWeight" id="crWeight" value="" /></p></td><td class="label" ><p>Dimension<input name="l" type="text" class="box" id="l" size="3" maxlength="255" value="" />x<input name="b+j" type="text" class="box" id="b" size="3" maxlength="255" value="" />x<input name="h" type="text" class="box" id="h" size="3" maxlength="255" value="" /></p> </td></tr></table>';
document.getElementById("my_div").appendChild(divTag);
}
else if (d2==d1)
{
alert("Box No. has reached max limit");
}
else if(d2>d1)
{
alert("OOps more than total numbers ");
}
}
else
{
alert("Please enter total Box/Box nos .");
}
}
</script>
<script type="text/javascript">
function calc(){
if ( isNaN(document.getElementById("l").value) == true )
{
alert('The value is not numeric');
document.getElementById("l").value.focus();
document.getElementById("l").value.select();
return false;
}
if ( isNaN(document.getElementById("b").value) == true )
{
alert('The value is not numeric');
document.getElementById("b").value.focus();
document.getElementById("b").value.select();
return false;
}
if ( isNaN(document.getElementById("h").value) == true )
{
alert('The value is not numeric');
document.getElementById("h").value.focus();
document.getElementById("h").value.select();
return false;
}
if ( isNaN(document.getElementById("boxno").value) == true )
{
alert('The value is not numeric');
document.getElementById("boxno").value.focus();
document.getElementById("boxno").value.select();
return false;
}
var l1 =parseFloat(document.getElementById("l").value);
var b1 =parseFloat(document.getElementById("b").value);
var h1 =parseFloat(document.getElementById("h").value);
var box = parseFloat(document.getElementById("boxno").value);
var r =(l1*b1*h1/6000)*box;
( document.getElementById("grWeight").value) = r;
}
</script>
<html>
<table>
<tr>
<td width="174" class="label">Total Boxes</td>
<td colspan="3" class="content"><input name="ttlBoxes" type="text" class="box" id="ttlBoxes" size="20" maxlength="255"
value="" /></td>
</tr>
<tr id=myrow >
<td class="label">Box</td>
<td class="label">
<select id="boxtype" name="boxtype">
<option value="select">Select</option>
<option value="Amb">Amb</option>
<option value="Frz">Frz</option>
<option value="Ref">Ref</option>
<option value="Gen">Gen</option>
</select>
<select id="box" name="box">
<option value="select">Select</option>
<option value="OurBox">Our Box</option>
<option value="DrBox">Dr.Box</option>
<option value="Other">Other</option>
</select>
Gross Weight
<input type="text" name="grWeight" id="grWeight" value="0" onclick="calc(this)" readonly="readonly"/></td>
<td class="label"><p>Box Nos.
<input name="boxno" type="text" class="box" id="boxno" size="20" maxlength="255" value=""
/>
</p>
<p>Chargeble Weight
<input type="text" name="crWeight" id="crWeight" value="" />
</p></td>
<td class="label">
<p>Dimension
<input name="l" type="text" class="box" id="l" size="3" maxlength="255"
value="" />
x
<input name="b" type="text" class="box" id="b" size="3" maxlength="255"
value="" />
x
<input name="h" type="text" class="box" id="h" size="3" maxlength="255"
value="" />
</p>
<p>
<input type="button" value="Add" onClick="add()">
</p></td>
</tr>
<tr>
<td class="label"></td>
<td class="label" colspan="3">
<div id="my_div" name="my_div">
<!--<input type="button" value="Add" onClick="add()">-->
</div></td>
</tr>
</table>
</html>
I want to show calculation of gross weight in Gross weight field using function calc().
Now firstime its working. Getting calculation but after adding div using function add(),function calc() is not working.there is no calculation of Gross weight by function add().I want to show calculation repeatatively.
Please help me.