I would like to have someone to help me out with my program.
Users are able to add items if they wish for the Monthly Claims Charges System.
I did not manage to do the calculation part of the program.
Could someone help me? :) Here is the program:
[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Monthl y claims Charges</title>
<script language="javas cript">
<!-- Counting the input fields -->
function dosum()
{
var i = 0;
while(i < document.temps. item1.length){
document.temps. total1.value += parseFloat(docu ment.temps.item 1[i].value);
window.alert("T he number entered is: " + document.temps. item1[i].value);
return parseFloat(docu ment.temps.tota l1.value);
i++;}
}
<!-- End of counting function -->
<!-- Adding first row -->
var nextSubject = new Array(100) ;
var counter = 1 ;
function addRow(){
var tbody = document.getEle mentById("table 1").getElements ByTagName("tbod y")[0];
if (!tbody.crow){
var rows=tbody.getE lementsByTagNam e('TR');
tbody.crow=rows[rows.length-1];
}
var nrow=tbody.crow .cloneNode(true );
var eles=nrow.getEl ementsByTagName ('*');
for (var zxc0=0;zxc0<ele s.length;zxc0++ ){
if (eles[zxc0].name){ eles[zxc0].name=eles[zxc0].name.replace(' 0',counter); }
if (eles[zxc0].id){ eles[zxc0].id=eles[zxc0].id.replace('0' ,counter); }
if (eles[zxc0].tagName=='INPU T'){ eles[zxc0].value=''+eles[zxc0].value; } // change to eles[zxc0].value='' when ready
if (eles[zxc0].tagName=='SELE CT'){ eles[zxc0].selectedIndex= 0; }
}
counter++;
tbody.appendChi ld(nrow);
}
<!-- end of first row -->
</script>
</head>
<body>
<form NAME="temps">
<P align=center><S TRONG>Monthly claim
Charges</STRONG></P>
<P align=center>MO NTH: _______________ ___</P>
<P align=center>NA ME:____________ _______________ _______________ </P>
<table border="0" align="center" width = "80%" id="table1" bgcolor="#99cc9 9">
<tr>
<td><STRONG>ITE MS</STRONG></td>
<td>
<P align=left><STR ONG>PAGE REF.</STRONG></P></td>
<td>
<P align=center><S TRONG> RM</STRONG></P></td>
</tr>
<tr >
<td><STRONG>1 ) PETROL,PARKING
& TRAVELLING  ; &n bsp;   ; </STRONG></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Petrol / Mileage Claims</td>
<td><INPUT maxLength=10 size=10> & nbsp; &nbs p; & nbsp; &nbs p; </td>
<td>
<P align=right><IN PUT maxLength=10 size=10 name="item1" onChange="dosum ()" value="0"></P></td>
</tr>
<tr>
<td>Parking, Toll and Touch & Go (Top Up)</td>
<td><INPUT maxLength=10 size=10></td>
<td>
<P align=right><IN PUT maxLength=10 size=10 name="item1" onChange="dosum ()" value="0"></P></td>
</tr>
<tr>
<td>Taxi Fare, Air Fare, Bus Fare and etc</td>
<td><INPUT maxLength=10 size=10></td>
<td>
<P align=right><IN PUT maxLength=10 size=10 name="item1" onChange="dosum ()" value="0"></P></td>
</tr>
<tr>
<td>
<INPUT maxLength=30 size=30
name=" "
="32142">
</td>
<td><INPUT maxLength=10 size=10
name=""
="32144"></td>
<td>
<P align=right><IN PUT maxLength=2 size=10
name="item1" onChange="dosum ()" value="0"></P></td>
</tr></table>
<P align=left>&nbs p; & nbsp; &nbs p; & nbsp;
&nb sp; &nb sp; &nb sp; <INPUT onclick=addRow( ); type=button value="Insert Row"> &nbs p; & nbsp; &nbs p; & nbsp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp;
<TABLE align=center border=0 width = "80%">
<TR>
<TD>
<P
align=right>&nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; Total: <INPUT
maxLength=10 size=10 name ="total1" input></P>
</TD></TR></TABLE></P>
</form>
</body>
</html>[/HTML]
Users are able to add items if they wish for the Monthly Claims Charges System.
I did not manage to do the calculation part of the program.
Could someone help me? :) Here is the program:
[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Monthl y claims Charges</title>
<script language="javas cript">
<!-- Counting the input fields -->
function dosum()
{
var i = 0;
while(i < document.temps. item1.length){
document.temps. total1.value += parseFloat(docu ment.temps.item 1[i].value);
window.alert("T he number entered is: " + document.temps. item1[i].value);
return parseFloat(docu ment.temps.tota l1.value);
i++;}
}
<!-- End of counting function -->
<!-- Adding first row -->
var nextSubject = new Array(100) ;
var counter = 1 ;
function addRow(){
var tbody = document.getEle mentById("table 1").getElements ByTagName("tbod y")[0];
if (!tbody.crow){
var rows=tbody.getE lementsByTagNam e('TR');
tbody.crow=rows[rows.length-1];
}
var nrow=tbody.crow .cloneNode(true );
var eles=nrow.getEl ementsByTagName ('*');
for (var zxc0=0;zxc0<ele s.length;zxc0++ ){
if (eles[zxc0].name){ eles[zxc0].name=eles[zxc0].name.replace(' 0',counter); }
if (eles[zxc0].id){ eles[zxc0].id=eles[zxc0].id.replace('0' ,counter); }
if (eles[zxc0].tagName=='INPU T'){ eles[zxc0].value=''+eles[zxc0].value; } // change to eles[zxc0].value='' when ready
if (eles[zxc0].tagName=='SELE CT'){ eles[zxc0].selectedIndex= 0; }
}
counter++;
tbody.appendChi ld(nrow);
}
<!-- end of first row -->
</script>
</head>
<body>
<form NAME="temps">
<P align=center><S TRONG>Monthly claim
Charges</STRONG></P>
<P align=center>MO NTH: _______________ ___</P>
<P align=center>NA ME:____________ _______________ _______________ </P>
<table border="0" align="center" width = "80%" id="table1" bgcolor="#99cc9 9">
<tr>
<td><STRONG>ITE MS</STRONG></td>
<td>
<P align=left><STR ONG>PAGE REF.</STRONG></P></td>
<td>
<P align=center><S TRONG> RM</STRONG></P></td>
</tr>
<tr >
<td><STRONG>1 ) PETROL,PARKING
& TRAVELLING  ; &n bsp;   ; </STRONG></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Petrol / Mileage Claims</td>
<td><INPUT maxLength=10 size=10> & nbsp; &nbs p; & nbsp; &nbs p; </td>
<td>
<P align=right><IN PUT maxLength=10 size=10 name="item1" onChange="dosum ()" value="0"></P></td>
</tr>
<tr>
<td>Parking, Toll and Touch & Go (Top Up)</td>
<td><INPUT maxLength=10 size=10></td>
<td>
<P align=right><IN PUT maxLength=10 size=10 name="item1" onChange="dosum ()" value="0"></P></td>
</tr>
<tr>
<td>Taxi Fare, Air Fare, Bus Fare and etc</td>
<td><INPUT maxLength=10 size=10></td>
<td>
<P align=right><IN PUT maxLength=10 size=10 name="item1" onChange="dosum ()" value="0"></P></td>
</tr>
<tr>
<td>
<INPUT maxLength=30 size=30
name=" "
="32142">
</td>
<td><INPUT maxLength=10 size=10
name=""
="32144"></td>
<td>
<P align=right><IN PUT maxLength=2 size=10
name="item1" onChange="dosum ()" value="0"></P></td>
</tr></table>
<P align=left>&nbs p; & nbsp; &nbs p; & nbsp;
&nb sp; &nb sp; &nb sp; <INPUT onclick=addRow( ); type=button value="Insert Row"> &nbs p; & nbsp; &nbs p; & nbsp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp;
<TABLE align=center border=0 width = "80%">
<TR>
<TD>
<P
align=right>&nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; &nb sp; Total: <INPUT
maxLength=10 size=10 name ="total1" input></P>
</TD></TR></TABLE></P>
</form>
</body>
</html>[/HTML]
Comment