aki2all 0 Newbie Poster
 include 'functions.php';
 header("Location: index.html");

    $session = $_SESSION['empno'];

    $dbName = mysql_query("SELECT ename FROM employee
                        WHERE empno = '$session'") or die(mysql_error());
    $nameResult = mysql_fetch_array($dbName);
    $name = $nameResult['ename'];

    $reqno = $_GET['id']; //echo $reqno; exit;
    $amtApproved = $_GET['amtApproved'];    
    $query = mysql_query("SELECT * FROM requisition
                        WHERE reqno = '$reqno'") or die(mysql_error());
        $result = mysql_fetch_assoc($query);
        $online1 = $result['online']; //echo $purpose; //exit;
        $cash1 = $result['cash']; //echo $amount; exit;
    //$id = $reqno;

    if (isset($_POST['submit'])){
        //echo $id; exit;
        //echo $reqno; exit;//= $_GET['id'];
        $online = mysql_real_escape_string($_POST['online']); //echo $purpose1;
        $cash = mysql_real_escape_string($_POST['cash']); //echo $amount1; exit;
        $sum = $online+$cash;
        if($sum==$amtApproved && $online1!=NULL && $cash1!=NULL){
            $update = mysql_query("UPDATE requisition
                                SET online = '".$online."', cash = '".$cash."'
                                WHERE reqno = '$reqno'") or die(mysql_error());
            header ("Location: main.php");
        echo "Wrong entry!!";

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<style type="text/css">
body {
    background-image: url(images/iicb-06.jpg);
.style3 {font-size: 24px}


<div align="center">
  <style type="text/css">

  <body bgcolor = "#d3dfca">
  <style type="text/css">
.style3 {
    font-weight: bold;
    color: #fdfdsd;
    font-size: large;

  <img src="images/iicb.png">
<h1 align="center">Split Your Approved Amount</h1>
<div align="center">

?> </div>
<form action="<? $_SERVER['PHP_SELF']?>" method="post"><table align="center" cellpadding="5" cellspacing="5">
<tr><th><span class="style3">Requisition Number</span></th>
<td><span class="style3"></span><?php echo $reqno?></td>
<tr><th><span class="style3">Your Approved Amount</span></th>
<td><?php  echo $amtApproved ?></td></tr>
<tr><th>Online</th><td><input type="text" name="online" /></td></tr>
<tr><th>Cash</th><td><input type="text" name="cash" /></td></tr>
<div align="center"><input type="submit" name="submit" id="submit" value="Submit" /></div>


I want to have a javascript that automatically calculates the difference of the filled-in amount and the total amount.
Please Help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.