...

View Full Version : Changing Text Color when button is clicked



dave700800
12-10-2007, 04:28 PM
I am trying to Change the text color of my buttons when they are clicked can somone tell me where to insert and what line of code needs inserted. I am very new to this, i kinda just got thrown into it at work here and am trying to make it happen so any help is greatly appreciated.

// subfileWidget.js

document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) {
retnode.push(elem[i]);
}
}
return retnode;
};


document.body.oldOnload = document.body.onload;
document.body.onload = function (){
if(document.body.oldOnload){
document.body.oldOnload();
}
initSubfileWidget();
};

// newFunction
function initSubfileWidget() {
var subfileTables = document.getElementsByClassName('HATSTABLE');
//alert('found :' + subfileTables.length);
for(var i = 0; i < subfileTables.length; i++){
var radios = subfileTables[i].getElementsByTagName('input');
//alert('radios: ' + radios.length);
for (var j = 0; j < radios.length; j++){
if(radios[j].type.toUpperCase() == "RADIO"){
//alert('value' + radios[j].value);
radios[j].oldOnClick = radios[j].onclick
radios[j].onclick = new Function("if(this.oldOnClick)this.oldOnClick();highlightRow(this);");
attachCellEvent(radios[j]);
}
}
}
}

function attachCellEvent(element){
var tr = element.parentNode;
while(tr.tagName.toUpperCase() != "TR"){
tr = tr.parentNode;
}
var cells = tr.getElementsByTagName('td');
for(var cellIndex = 0; cellIndex < cells.length; cellIndex ++){
var functionText = cells[cellIndex].onclick;
var regexp = /HATSForm\.subfile\_radiobutton_\d+/;
var radioName = regexp.exec(functionText);
cells[cellIndex].oldOnclick = cells[cellIndex].onclick;
cells[cellIndex].onclick = new Function("if(this.oldOnlclick)this.oldOnclick();"+ (radioName ? radioName + ".click();" : ""));
}
}

function highlightRow(element){
//alert('highlighting row');
clearAllHighlighting(element);
var tr = element.parentNode;
while(tr.tagName.toUpperCase() != "TR"){
tr = tr.parentNode;
}
tr.oldStyle = tr.className;
tr.className = 'HATSTABLESELECTEDROW';
}


function clearAllHighlighting(element){
var table = element.parentNode;
while(table.tagName.toUpperCase() != "TABLE"){
table = table.parentNode;
}
var rows = table.getElementsByTagName("TR");
for (var k = 0; k < rows.length; k++){
if(rows[k].oldStyle){
rows[k].className = rows[k].oldStyle;
}
}
}

rnd me
12-10-2007, 05:27 PM
<input value="click me" type="text" onclick="this.style.color='red' " />



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum