@acoder
The short answer is see: parseResults() function at the bottom of this message. But I have given you the entire flow
1. How I stream out the page from the server
2. How the user can change the status of a contact.
3. my ajax call which goes out to make the change and comes back to update the color of the text of the name of the person's status that was changed.
On my server side scripting I use the variable "wkRowBgColor" to alternate the color of each line like this
-
-
puts([ <td])
-
puts([ id="name_]+c["CONTACTKEY"].value+["])
-
puts([ nowrap="nowrap"])
-
puts([ style="background-color:]+wkRowBgColor+[;"])
-
puts([ >]+ cValue +[</td>])
-
-
I do not want to change the line background color, but when I update (change the color of the text) to indicate the status has changed then the background color also changes.
In the column next to the name on the table are 3 radio buttons which when clicked calls the changeStatus() function:
-
puts([ <td])
-
puts([ id="attr_]+c["CONTACTKEY"].value+["])
-
puts([ nowrap="nowrap"])
-
puts([ style="background-color:]+wkRowBgColor+[;"])
-
puts([ >])
-
puts([Export]+;
-
[<input ]+;
-
[type="radio" ]+;
-
[id="exp_]+c["CONTACTKEY"].value+["]+;
-
[name="]+c["CONTACTKEY"].value+[" ]+;
-
[value="Save" ]+;
-
[onclick="changeStatus(this);"]+;
-
[ checked ]+;
-
[/> ]+;
-
[Remove from list ]+;
-
[<input ]+;
-
[type="radio" ]+;
-
[id="rem_]+c["CONTACTKEY"].value+["]+;
-
[name="]+c["CONTACTKEY"].value+[" ]+;
-
[value="Delete" ]+;
-
[onclick="changeStatus(this);"]+;
-
[/>]+;
-
[Delete From Company ]+;
-
[<input ]+;
-
[type="radio" ]+;
-
[id="del_]+c["CONTACTKEY"].value+["]+;
-
[name="]+c["CONTACTKEY"].value+[" ]+;
-
[value="RemoveFromCompany" ]+;
-
[onclick="changeStatus(this);"]+;
-
[/>]+;
-
[</td>])
-
Then here is my ajax call that updates the table after the status has changed.
-
var xmlHttp;
-
-
function createXMLHttpRequest() {
-
if (window.ActiveXObject) {
-
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
-
}else if (window.XMLHttpRequest) {
-
xmlHttp = new XMLHttpRequest();
-
}
-
}
-
-
function changeStatus(obj)
-
{
-
var cKey = obj.id.substring(4);
-
var cAction = obj.id.substring(0,4);
-
var cLocation = document.getElementById("wkWhere").value.substring(3,13);
-
-
createXMLHttpRequest();
-
var url = "Process.exe?timeStamp=" + new Date().getTime();
-
var queryString = createQueryString(cKey, cAction, cLocation) + "&method=POST";
-
xmlHttp.onreadystatechange = handleStateChange;
-
xmlHttp.open("POST", url, true);
-
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
-
xmlHttp.send(queryString);
-
}
-
-
function createQueryString(cKey, cAction, cLocation) {
-
var queryString = "CONTACTKEY=" + cKey;
-
queryString += "&action=" + cAction;
-
queryString += "&location=" + cLocation;
-
return queryString;
-
}
-
-
function handleStateChange() {
-
if (xmlHttp.readyState == 4) {
-
if (xmlHttp.status == 200) {
-
parseResults();
-
}
-
}
-
}
-
-
function parseResults() {
-
-
var returnedString = xmlHttp.responseText;
-
var aReturn = new Array();
-
-
aReturn = returnedString.split(';');
-
-
if ( aReturn[0] == "An error occured") {
-
eAlert = aReturn[0]+"\n"
-
-
if ( aReturn[1] == "Invalid client Id") {
-
eAlert += aReturn[1]+" "+document.getElementById("ID").value+"\n"
-
}else{
-
eAlert += aReturn[1]+"\n"
-
}
-
-
eAlert += aReturn[2]+"\n"
-
eAlert += aReturn[3]
-
alert( eAlert );
-
}else{
-
var elem = document.getElementById(aReturn[0]) ;
-
if (aReturn[1] == 'deleted')
-
{
-
elem.setAttribute('style','color: red; text-decoration: line-through;');
-
document.getElementById(aReturn[2]).innerHTML = "deleted" ;
-
}else{
-
if (aReturn[1] == 'F')
-
{
-
elem.setAttribute('style','color: green; text-decoration: line-through; ');
-
}else{
-
elem.setAttribute('style','color: black; text-decoration: none;');
-
}
-
}
-
}
-
}
-
As you can see by parseResults() function all I change is the text color, but it seems like the background color of the cell inherits the background color of the form outside the table, even though I did not touch that attribute.
My question really though was - Is it possible with my javaScript to read the current line's background color, save it to a variable, then update the background color after I make the text color change?
The problem is I don't know if the change is occurring to a white or light grey background color.