By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,550 Members | 1,733 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,550 IT Pros & Developers. It's quick & easy.

change color of text box when value entered into text box

P: 1
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
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. error_reporting(E_ALL^E_NOTICE);
  3. $dbhost = "localhost";
  4. $dbuser = "root";
  5. $dbpass = "";
  6. $dbname = "purchase";
  7. mysql_connect($dbhost, $dbuser, $dbpass);
  8. mysql_select_db($dbname) or die(mysql_error());
  9.  
  10. $qry_result= mysql_query("SELECT NRC FROM currentnfb") or die(mysql_error());
  11. $row=mysql_fetch_array($qry_result);
  12. $num=$row[NRC];
  13.  
  14. $description=$_POST['description'];
  15. $number=$_POST['number'];
  16. $text1=$_POST['text1'];
  17. $year1=$_POST['year1'];
  18. $text=$_POST['text'];
  19. $fileno=$number. '-' .$text1. '/' .$year1. '/' .$text;
  20. $Nameoffirm=$_POST['Nameoffirm'];
  21. $exp=$_POST['exp'];
  22. $year6=$_POST['year6'];
  23. $month6=$_POST['month6'];
  24. $day6=$_POST['day6'];
  25. $dateofsanction=$year6. '-' .$month6. '-' .$day6;
  26. $year5=$_POST['year5'];
  27. $month5=$_POST['month5'];
  28. $day5=$_POST['day5'];
  29. $dateofpo=$year5. '-' .$month5. '-' .$day5;
  30. $indentno=$_POST['indentno'];
  31. $year=$_POST['year'];
  32. $month=$_POST['month'];
  33. $day=$_POST['day'];
  34. $dateofindent=$year. '-' .$month. '-' .$day;
  35. $billno=$_POST['billno'];
  36. $year4=$_POST['year4'];
  37. $month4=$_POST['month4'];
  38. $day4=$_POST['day4'];
  39. $dateofbillno=$year4. '-' .$month4. '-' .$day4;
  40. $BLno=$_POST['BLno'];
  41. $billpass=$_POST['billpass'];
  42. $billamt=$_POST['billamt'];
  43. if($billamt=$exp)
  44. {
  45. billamt.style.background='green';}
  46. else
  47. {
  48. billamt.style.background='red';}
  49. $year3=$_POST['year3'];
  50. $month1=$_POST['month1'];
  51. $day1=$_POST['day1'];
  52. $dateofbill=$year3. '-' .$month1. '-' .$day1;
  53. $availbal=$_POST['availbal'];
  54. $progbal=$_POST['progbal'];
  55. $remark=$_POST['remark'];
  56. $availbal=$num;
  57. $progbal=$num-$exp;
  58.  
  59.  
  60.  
  61.  
  62. $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')";
  63. mysql_query($query)or die('error');
  64. echo"database update with:" .$expend."".$availbal."".$progbal."".$billamt."";
  65. $NRC=$progbal;
  66. $sql = "UPDATE currentnfb
  67.        SET NRC = '$progbal'";
  68.        $retval = mysql_query( $sql);
  69. if(! $retval )
  70. {
  71.   die('Could not update data: ' . mysql_error());
  72. }
  73. echo "Updated data successfully\n";
  74.  
  75. ?>
  76.  
Apr 10 '13 #1
Share this Question
Share on Google+
1 Reply


100+
P: 1,059
how about onchange='this.style.color="newColor"'?
Apr 10 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.