Jump to content

Textbox array


tolearn

Recommended Posts

Hi,

I have a form in which i have to calculate the leave and late days of employees.

The coding is as follows:

<!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">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

<script language="javascript">

/*function calc()

{

var a=parseInt(document.form1.num1.value);

var b=parseInt(document.form1.num2.value);

var c=a-b;

document.form1.result.value=c;

}*/

 

function calc()

{

var days=parseFloat(document.form1.days.value);

var late=parseInt(document.form1.late.value);

var quotient=parseInt(late/3);

var reminder=parseInt(late%3);

late_days=quotient*0.5;

tot_leave=days+late_days;

document.form1.total_leave.value=tot_leave;

document.form1.late_remaining.value=reminder;

}

function calc1()

{

var cut=parseInt(document.form1.cut.value);

leave_cut=tot_leave-cut;

document.form1.leave_remaining.value=leave_cut;

}

</script>

</head>

 

<body>

<form id="form1" name="form1">

<!--<input type="text" name="num1" /> +

<input type="text" name="num2" onblur="calc()" /> =

<input type="text" name="result" />-->

Leave: <input type="text" name="days" /><br />

Late: <input type="text" name="late" onblur="calc()" /><br />

Total Leave: <input type="text" name="total_leave" /><br />

Late Remaining: <input type="text" name="late_remaining" /><br />

Cut: <input type="text" name="cut" onblur="calc1()" /><br />

Leave Remaining: <input type="text" name="leave_remaining" /><br />

</form>

</body>

</html>

 

 

But i want this calculation to be done for more than one employee. The number of employees is taken from the database and i have to create an array and then have to calculate.

How to do this?

Link to comment
https://forums.phpfreaks.com/topic/120819-textbox-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.