hello friends
good to see you all.
i am very new to this forum and also for java script.
i want to subtract two values using java script,and the total value want to save in another text field.
in that two values one is from database...
another value will type by user..

help needed
here is my code..
PHP Code:
<?php
session_start
();
if(!isset(
$_SESSION['username']))
{
    
header("location:index.php");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>School  Database System</title>
<link rel="stylesheet" type="text/css" href="css/styles.css" />
<link rel="stylesheet" type="text/css" href="css/table.css" />
<link rel="stylesheet" type="text/css" href="calendar.css" />
<script type="text/javascript" src="js/autofill.js"></script>
<script language="JavaScript" src="js/gen_validatorv4.js" type="text/javascript" xml:space="preserve"></script>
<script type="text/javascript" src="datepickercontrol.js"></script>
<script language="JavaScript">
if 
(
navigator.platform.toString().toLowerCase().indexOf("linux") != -1)
{
document.write('<link type="text/css" rel="stylesheet" href="datepickercontrol_lnx.css">');
}
else
{
document.write('<link type="text/css" rel="stylesheet" href="datepickercontrol.css">');
}
</script>
<script type="text/javascript">
function showHide(id){
   el = document.getElementById(id);
   el.style.display = (el.style.display != 'block')? 'block' : 'none';
}
</script>
<script language="javascript">
function doMath() 
{
    var oldbal= parseFloat(document.getElementById('totalfees').value);
    var paid= parseFloat(document.getElementById('paid').value);
    var totalfees = parseFloat(oldbal) - parseFloat(paid);
    document.getElementById('totalfees').value = totalfees;
}
</script>

</HEAD>
<body>

<div id="wrapper">
<div id="header">
<h1>School Database System</h1>
</div>

<div id="navigation"> 
<?php
include("menu.php");
?>
</div>
<div id="content">
<form name="form" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
 <table width="918" border="0">
  <tr>
    <td width="222" height="300">&nbsp;</td>
    <td width="686">
     <table width="556" border="0" class="imagetable">
      <tr>
        <td width="550" height="30">
       <?php
error_reporting 
(E_ALL E_NOTICE);
include(
"config.php");
if(isset(
$_POST['update']))
{
$class_code=$_POST['class_code'];
$class_name=$_POST['class_name'];
$class_section=$_POST['class_section'];
$class_group=$_POST['class_group'];
$bill_type=$_POST['bill_type'];
$student_code=$_POST['student_code'];
$student_name=$_POST['student_name'];
$chk2=$_POST['chk2'];
$chk4=$_POST['chk4'];
$chk6=$_POST['chk6'];
$chk8=$_POST['chk8'];
$chk10=$_POST['chk10'];
$chk12=$_POST['chk12'];
$chk14=$_POST['chk14'];
$chk16=$_POST['chk16'];
$chk18=$_POST['chk18'];
$chk20=$_POST['chk20'];
$balfees=$_POST['totalfees'];

$sql=mysql_query("UPDATE fees_admin SET class_code='$class_code', class_name='$class_name', class_section='$class_section', class_group='$class_group', student_code='$student_code', student_name='$student_name' totalfees='$balfees' WHERE billtype_id='$billtype_id'",$conn);
if(
$sql)
{
echo
"<p><center><b><font color='green'>Course Order Added Successfully!</font></b></center></p>";
}
else
{
echo
"<p><center><b><font color='red'>Course Order Added Failed!</font></b>&nbsp;&nbsp;&nbsp;Click <a href='order.php'>&nbsp;HOME</a></center></p>";
}
}
?>  
<?php
$billtype_id 
$_GET['billtype_id'];
$result=mysql_query("select * from bill_type where billtype_id=$billtype_id");
while(
$res=mysql_fetch_array($result))
{
$class_code=$res['class_code'];
$class_name=$res['class_name'];
$class_section=$res['class_section'];
$class_group=$res['class_group'];
$bill_type=$res['bill_type'];
$student_code=$res['student_code'];
$student_name=$res['student_name'];
$totalfees=$res['totalfees'];
}
?>
      </td>
        </tr>
        </table>
    
<table width="599" border="0" class="imagetable">
<tr>
    <td width="92" height="30">Class Code</td>
  <td width="152"><input name="class_code" type="text" value="<?php echo $class_code;?>"></td>
 <td width="150" height="42">Class Name</td>
        <td width="185"><input name="class_code" type="text" value="<?php echo $class_name;?>"></td>
       </tr>
<tr>
        <td height="53">Class Section</td>
        <td><input name="class_code" type="text" value="<?php echo $class_section;?>"></td>
     <td height="53">Class Group</td>
        <td><input name="class_code" type="text" value="<?php echo $class_group;?>"></td>
</tr>
<tr>
        <td height="53">Student Code</td>
        <td><input name="class_code" type="text" value="<?php echo $student_code;?>"></td>
     <td height="53">Student Name</td>
        <td><input name="class_code" type="text" value="<?php echo $student_name;?>"></td>
</tr>
<tr>
<td height="39">Bill Type</td>
<td><input name="class_code" type="text" value="<?php echo $bill_type;?>"></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
    <td height="33">&nbsp;</td>
    <td align="right">&nbsp;</td>
  <td>Total Fees :</td>    
  <td><input name="total" type="text" id="oldbal" value="<?php echo $totalfees;?>" readonly="true" style="background-color:#FFFFFF"></td>
</tr> 
<tr>
    <td height="33">&nbsp;</td>
    <td align="right">&nbsp;</td>
  <td>Paid :</td>
  <td><input type="text" id="paid" name="paid" onKeyUp="doMath();"></td>
</tr> 
<tr>
    <td height="33">&nbsp;</td>
    <td></td>
  <td>Bal Fees</td>
  <td><input name="totalfees" type="text"  id="totalfees" style="background-color:#FFFFFF"></td>
</tr> 

<tr>
<td align="center">&nbsp;</td>
<td align="center"><input type="submit" name="submit" value="Submit"></td>
<td><input name="reset" type="reset" value="Clear"></td>
    <td><a href="fees_admin.php" style="text-decoration:none;"><input type="button" value="View/Edit" class="button">
          </a></td>
</tr>
</table>
</td>
</tr>
</table>    
</form>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
//<![CDATA[//You should create the validator only after the definition of the HTML form
  var frmvalidator  = new Validator("form");
  frmvalidator.addValidation("course_code","dontselect=000","Please Choose Code");
  frmvalidator.addValidation("course_name","dontselect=000","Please Choose Name");
  frmvalidator.addValidation("course_year","dontselect=000","Please Choose Year");
  frmvalidator.addValidation("course_semester","dontselect=000","Please Choose Semester");
  frmvalidator.addValidation("courseorder_date","req","Please Select Order Date"); 
  frmvalidator.addValidation("bill_type","req","Please Enter Bill Type");  
  frmvalidator.addValidation("selection","req","Please Fill The Selection");   
//]]></script>
</div>
<?php
include("footer.php");
?>
</div>
</body>
</html>