change color of text box when value entered into text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rrrkkk
    New Member
    • Apr 2013
    • 1

    change color of text box when value entered into text box

    Hello

    Actually I am working on php I have created a insertion form in which I need when entering a value into bill amt text box then it should be compare with exp value if it is not equal then the color of bill amt text box should be change.

    here is code
    Code:
    <?php
    error_reporting(E_ALL^E_NOTICE);
    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = "";
    $dbname = "purchase";
    mysql_connect($dbhost, $dbuser, $dbpass);
    mysql_select_db($dbname) or die(mysql_error());
    
    $qry_result= mysql_query("SELECT NRC FROM currentnfb") or die(mysql_error());
    $row=mysql_fetch_array($qry_result);
    $num=$row[NRC];
    
    $description=$_POST['description'];
    $number=$_POST['number'];
    $text1=$_POST['text1'];
    $year1=$_POST['year1'];
    $text=$_POST['text'];
    $fileno=$number. '-' .$text1. '/' .$year1. '/' .$text;
    $Nameoffirm=$_POST['Nameoffirm'];
    $exp=$_POST['exp'];
    $year6=$_POST['year6'];
    $month6=$_POST['month6'];
    $day6=$_POST['day6'];
    $dateofsanction=$year6. '-' .$month6. '-' .$day6;
    $year5=$_POST['year5'];
    $month5=$_POST['month5'];
    $day5=$_POST['day5'];
    $dateofpo=$year5. '-' .$month5. '-' .$day5;
    $indentno=$_POST['indentno'];
    $year=$_POST['year'];
    $month=$_POST['month'];
    $day=$_POST['day'];
    $dateofindent=$year. '-' .$month. '-' .$day;
    $billno=$_POST['billno'];
    $year4=$_POST['year4'];
    $month4=$_POST['month4'];
    $day4=$_POST['day4'];
    $dateofbillno=$year4. '-' .$month4. '-' .$day4;
    $BLno=$_POST['BLno'];
    $billpass=$_POST['billpass'];
    $billamt=$_POST['billamt'];
    if($billamt=$exp)
    {
    billamt.style.background='green';}
    else
    {
    billamt.style.background='red';}
    $year3=$_POST['year3'];
    $month1=$_POST['month1'];
    $day1=$_POST['day1'];
    $dateofbill=$year3. '-' .$month1. '-' .$day1;
    $availbal=$_POST['availbal'];
    $progbal=$_POST['progbal'];
    $remark=$_POST['remark'];
    $availbal=$num;
    $progbal=$num-$exp;
    
    
    
    
    $query="insert into nfone(description,fileno,Nameoffirm,exp,dateofsanction,dateofpo,indentno,dateofindent,billno,dateofbillno,BLno,billpass,billamt,dateofbill,availbal,progbal,remark) values ('$description','$fileno','$Nameoffirm','$exp','$dateofsanction','$dateofpo','$indentno','$dateofindent','$billno','$dateofbillno','$BLno','$billpass','$billamt','$dateofbill','$availbal','$progbal','$remark')";
    mysql_query($query)or die('error');
    echo"database update with:" .$expend."".$availbal."".$progbal."".$billamt."";
    $NRC=$progbal;
    $sql = "UPDATE currentnfb
           SET NRC = '$progbal'";
    	   $retval = mysql_query( $sql);
    if(! $retval )
    {
      die('Could not update data: ' . mysql_error());
    }
    echo "Updated data successfully\n";
    
    ?>
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    how about onchange='this. style.color="ne wColor"'?

    Comment

    Working...