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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.