473,654 Members | 3,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

change of bgcolor in a td of a dynamic table using javascript and ajax

15 New Member
Hi,
I have a dynamic table in my programme in php and the value of a particular cell gets reduced after every 3 seconds.I want to change the bg color of that particular into a different color when it reaches '0'.Pl help me.

thanks in advance

Suguna
Dec 21 '07 #1
4 2096
Markus
6,050 Recognized Expert Expert
Hi,
I have a dynamic table in my programme in php and the value of a particular cell gets reduced after every 3 seconds.I want to change the bg color of that particular into a different color when it reaches '0'.Pl help me.

thanks in advance

Suguna
Without the code you now have it's harder to help you because we have no idea what you're doing.

Please post the code [as much of it which is relevant] and we can help you add to it.

Good day
Dec 21 '07 #2
gagandeepgupta16
56 New Member
hi,

so have you tried out someting like this (its in javascript)
get the id of the td, for examle its td1
then
td1.style.backg round = "<some color>"

hope this helps you.

Hi,
I have a dynamic table in my programme in php and the value of a particular cell gets reduced after every 3 seconds.I want to change the bg color of that particular into a different color when it reaches '0'.Pl help me.

thanks in advance

Suguna
Dec 21 '07 #3
ravisuguna
15 New Member
Hi,
Here is my codings.Pl help me to change the bgcolor when the value in td11
becomes 0.
[PHP]<?
session_start() ;
?>
[/PHP][HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />-->
<!--<meta http-equiv="refresh" content="3" />-->
<title>Live Campaign Report</title>
<link href="main.css" rel="stylesheet " type="text/css" />
<style type="text/css">
.odd{background-color:#acbdee;}
.even{backgroun d-color:#cddeff;}
</style>
</head>
<body onload="alterna te('thetable')" >

<div id="header"><h2 ><img src="images/ptlogo.gif" /></h2>
<h1><img src="images/pt1.gif" width="870px" height="120px" /></h1>
</div
><DIV id=content-wrap>
<DIV id=content>
<DIV>
<H1 class="h1">Live Campaign Report</H1></DIV>
<STYLE>A {
TEXT-DECORATION: none
}
A:hover {
TEXT-DECORATION: none
}
A:visited {
TEXT-DECORATION: none
}
A:link {
TEXT-DECORATION: none
}
</STYLE>
[/HTML]
[PHP]<?PHP
include("conn.p hp");
$sel= mysql_select_db ("dialer");
include("functi on.php");

$fdate = date('d-m-Y');
$tdate = date('d-m-Y');

$tables=$_GET['tables'];

/* $fdate = $_POST['fdate'];
$tdate = $_POST['tdate'];
$submit = $_POST{'submit' };*/
?>
[/PHP]
[HTML]<body>


</div>
<DIV id=content-wrap>
<DIV id=content>

<br /><center>

<td colspan="4" align="center" >Select Campaign:
<form name="myform" method="POST" action="manage1 _campaign1.php" >

[/HTML][PHP]<?php
$list = mysql_list_tabl es ("dialer");

echo"&nbsp;&nbs p;&nbsp;<selec t name='tables' value=\'\' onChange='table pick();'>";
$i = 0;
//echo "<option value=''>Select Table</option>";
if($_GET['tables'])
{
echo "<option value='$tables' selected>$table s</option>";
}
while ($i < mysql_num_rows ($list)) {
$tb_names[$i] = mysql_tablename ($list, $i);

echo"<option value='$tb_name s[$i]'>$tb_names[$i]</option>";
$_SESSION['tables']=$_GET['tables'];
$i++;
}
echo "</select>";

?>
</form>
<?php

//echo $submit."<br>";
$fdate1 = explode("-",$fdate);
//print_r $fdate1;
$fdate3 = (strlen($fdate1[1]) == '1') ? "0".$fdate1[1] :$fdate1[1] ;
$fdate4 = (strlen($fdate1[0]) == '1') ? "0".$fdate1[0] :$fdate1[0] ;

$fdates = $fdate1[2]."-".$fdate3."-".$fdate4;


if($fdate == $tdate)
{
$tdates1 = mktime(0,0,0,$f date3,$fdate4+1 ,$fdate1[2]);
$tdates=date("Y-m-d", $tdates1);
// echo "Tomorrow is ".$tdates;

} else{
$tdate1 = explode("-",$tdate);
$tdate3 = (strlen($tdate1[1]) == '1') ? "0".$tdate1[1] :$tdate1[1] ;
$tdate4 = (strlen($tdate1[0]) == '1') ? "0".$tdate1[0] :$tdate1[0] ;

$tdates = $tdate1[2]."-".$tdate3."-".$tdate4;
}

//echo "<table cellspacing=5 cellpadding=5 border=0 align=center><t r class=h3><td>Fr om Date </td></tr>";


echo "<tr> <td>&nbsp;</td></tr></table>
<table border=1 width=95% align=center id='thetable'>
<tr><td class='th'>Fres hRecord</td></td><td class='th'>Sale </td>
<td class='th'>Call Back</td><td class='th'>Hang upAfterListen</td>
<td class='th'>Answ eringMachine</td><td class='th'> Busy</td>
<td class='th'>NotI nterested</td><td class='th'>Over Phone</td>
<td class='th'>Move Away</td><td class='th'>Lang uageBarrier</td>
<td class='th'>Cont act</td></tr>";

if($fdate != $tdate){

}
if ($tables=$table s)
{

$td1 = mysql_query("SE LECT count(*) FROM $tables where disposition ='1'");

//$td1 = mysql_query("SE LECT count(*) FROM asterisk.cdr where calldate ='$fdates' and length(src) =10 and lastapp <>'v%'");

$td11 = mysql_fetch_row ($td1);

$td2 = mysql_query("SE LECT count(*) FROM $tables where lastupdated >='$fdates' and disposition ='12'");

//$td1 = mysql_query("SE LECT count(*) FROM asterisk.cdr where calldate ='$fdates' and length(src) =10 and lastapp <>'v%'");

$td22 = mysql_fetch_row ($td2);

$td3 = mysql_query("SE LECT count(*) FROM $tables where lastupdated >='$fdates' and disposition ='0'");

//$td1 = mysql_query("SE LECT count(*) FROM asterisk.cdr where calldate ='$fdates' and length(src) =10 and lastapp <>'v%'");

$td33= mysql_fetch_row ($td3);

$td4 = mysql_query("SE LECT count(*) FROM $tables where lastupdated >='$fdates' and disposition ='2'");

//$td1 = mysql_query("SE LECT count(*) FROM asterisk.cdr where calldate ='$fdates' and length(src) =10 and lastapp <>'v%'");

$td44 = mysql_fetch_row ($td4);

$td5 = mysql_query("SE LECT count(*) FROM $tables where lastupdated >='$fdates' and disposition ='3'");

//$td1 = mysql_query("SE LECT count(*) FROM asterisk.cdr where calldate ='$fdates' and length(src) =10 and lastapp <>'v%'");

$td55 = mysql_fetch_row ($td5);

$td6 = mysql_query("SE LECT count(*) FROM $tables where lastupdated >='$fdates' and disposition ='4'");

//$td1 = mysql_query("SE LECT count(*) FROM asterisk.cdr where calldate ='$fdates' and length(src) =10 and lastapp <>'v%'");

$td66 = mysql_fetch_row ($td6);

$td7 = mysql_query("SE LECT count(*) FROM $tables where lastupdated >='$fdates' and disposition ='5'");

//$td1 = mysql_query("SE LECT count(*) FROM asterisk.cdr where calldate ='$fdates' and length(src) =10 and lastapp <>'v%'");

$td77 = mysql_fetch_row ($td7);

$td8 = mysql_query("SE LECT count(*) FROM $tables where lastupdated >='$fdates' and disposition ='6'");

//$td1 = mysql_query("SE LECT count(*) FROM asterisk.cdr where calldate ='$fdates' and length(src) =10 and lastapp <>'v%'");

$td88 = mysql_fetch_row ($td8);

$td9 = mysql_query("SE LECT count(*) FROM $tables where lastupdated >='$fdates' and disposition ='7'");

//$td1 = mysql_query("SE LECT count(*) FROM asterisk.cdr where calldate ='$fdates' and length(src) =10 and lastapp <>'v%'");

$td99 = mysql_fetch_row ($td9);

$td10 = mysql_query("SE LECT count(*) FROM $tables where lastupdated >='$fdates' and disposition ='9'");

//$td1 = mysql_query("SE LECT count(*) FROM asterisk.cdr where calldate ='$fdates' and length(src) =10 and lastapp <>'v%'");

$td1010 = mysql_fetch_row ($td10);

$td112 = mysql_query("SE LECT count(*) FROM $tables where lastupdated >='$fdates' and disposition ='11'");

//$td1 = mysql_query("SE LECT count(*) FROM asterisk.cdr where calldate ='$fdates' and length(src) =10 and lastapp <>'v%'");

$td1111 = mysql_fetch_row ($td112);



echo "<tr>
if($td11[0]==0)
{
echo"<td bgcolor="red">$ td11[0]</td>";
}
else
{
echo"<td bgcolor="green" >$td11[0]</td>";
}
<td>$td22[0]</td>
<td>$td33[0]</td>
<td>$td44[0]</td>
<td>$td55[0]</td>
<td>$td66[0]</td>
<td>$td77[0]</td>
<td>$td88[0]</td>
<td>$td99[0]</td>
<td>$td1010[0]</td>
<td>$td1111[0]</td></tr>";

}


?>[/PHP]
[HTML]</td>

<tr>

</tr>

</table>
</center>
</DIV>
</DIV><br />
<div id="footer">
<hr />
<table border=0 cellspacing=0 cellpadding=0>
<tr><td align="left">
<table width="400px">
<tr>
<td><a href="live_repo rts.php"><img src="images/back.jpg" /></a></td>
</tr>
</table>
</td>
<td>
<table width="450px">
<tr><td align="left">&c opy PeopleTech</td></tr>
</table>
</td>
<td>
<table><tr>
<td align="right">< a href="home.php" ><img src="images/home.jpg" /></a></td></tr></table>
</td>
</tr>
</table>
</div>
<script language="javas cript">
var sURL = unescape(window .location.pathn ame);
function tablepick(){
var val=document.my form.tables.val ue;
//document.form1. client.value = document.form1. store_id.value;
var ul =sURL +'?tables='+ val;
window.location .href =ul ;
//alert('hai');
}
function alternate(id){
if(document.get ElementsByTagNa me){
var table = document.getEle mentById(id);
var rows = table.getElemen tsByTagName("tr ");
for(i = 0; i < rows.length; i++){
//manipulate rows
if(i % 2 == 0){
rows[i].className = "even";
}else{
rows[i].className = "odd";
}
}
}
}
</script>
<script type="text/javascript">

function reFresh() {
location.reload (true)
}
window.setInter val("reFresh()" ,1000);

</script>
</body>
</html>[/HTML]

Suguna
Dec 21 '07 #4
acoder
16,027 Recognized Expert Moderator MVP
Why are you reloading the page every second?

You load the page once and change the td11 value every second.

Give the td which contains td11 an id, e.g. td11, then access the cell value using document.getEle mentById("td11" ).innerHTML. Then decrement by 1. This would be in your reFresh function. When it reaches 0, change the background colour using JavaScript.
Dec 22 '07 #5

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

Similar topics

5
4107
by: kj | last post by:
Is there a way to dynamically (e.g. upon onClick) change the bgColor attribute of a table cell? I tried cell.setAttribute("bgColor", someColor), where someColor was a string of the form "#RRGGBB", but nothing happened. Also, how can I set the mouse cursor to be an arrow when it hovers over these table cells? (It's an insertion bar now.) Thanks!
2
6156
by: Pete Kipe | last post by:
I'm not a JavaScript programmer...but I'm trying to put together a simple menu system for a new website and need a little help. I have the following script: <SCRIPT language=javascript> <!-- Hide JavaScript from Java-Impaired Browsers function NavRollOver(oTd) {if (!oTd.contains(event.fromElement)) {oTd.bgColor="#CC0000";}} function NavRollOut(oTd) {if (!oTd.contains(event.toElement))
22
7951
by: Saul | last post by:
I have a set of radio buttons that are created dynamically, after rendered I try loop thru this set by getting the length of the set, but I keep getting an error stating the element is undefined. I am using getElelementsByName since these are radio buttons, but it seems that the dynamic element is not seen!!! This is my code... please let me know if there is anything that I am doing wrong! - thanks ---- ....
3
9625
by: rlueneberg | last post by:
I want to change the color of an "a" child element inside a table cell via javascript. Is there any way to do that? Ps: there is no id assigned to child elements. I would like to discover the child element and change its color from the parent element if possible. <script type="text/javascript"> function HightLightCell(mycell, mybgcolor) { mycell.bgColor=mybgcolor; }
9
2948
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I got the core of the javascript from here: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm I noticed in the demo that sometimes the content takes a long
4
2429
by: gregincolumbus | last post by:
I am trying to get the financial calculation on this to trigger whenever there is a change to select1. Right now, the user has to click on select2 to trigger the changes. Ideally, a change of select1 1. trigger the population of select2 (and set it initially to 0) 2. make the text fields disappear 3. trigger the financial calculation to reflect the select1 choice. Any help would be greatly appeciated !
5
3668
by: plsHelpMe | last post by:
How to create dynamic javascript arrays using dojo toolkits Hello frens, I am in a big trouble. My objective is: I am having some categories shown by differnent radio buttons, on the click of a particular radio button i making an ajax call using dojo and retirieving the data corresponding to that category. Now i am suppose to create array of that data using the javascript dynamically. Can anyone please help me for the same. For your...
8
1920
by: tuananh87vn | last post by:
i have a sample code like below: index.html <script language='javascript'> //start xmlhttprequest if (window.XMLHttpRequest) //for IE 7 & FF { request=new XMLHttpRequest(); }
5
4456
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know if I have the entirely wrong approach, but my code is below. Any or all help is appreciated! What currently happens is that the getdivision.php script works perfectly and gives me an entire table of correct data. The problem is that when I click...
0
8379
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8494
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.