I was just playing around with javascript today and i wanted to change the style of a table element with javascript.
The code i am using:
[code=javascript]
ChangeIt(id){
var target = document.getEle mentById(id)
var newColor = "#00ff33"
target.style.co lor = newColor
}
[/code]
The php (this is from withing a while loop):
[php]
echo("<tr bgcolor=".$bgco lor.">
<td id=\"s".$counte r."\" onclick=\"Chang eIt('s".$counte r."');\">\n") ;
echo $counter;
$counter++; //increment counter
echo("</td><td>\n");
echo($row['url']);
echo("</td><td>\n");
echo($row['Util_Uploaded']);
echo("</td></tr>\n");
}
[/php]
I'm trying to get an onclick event where it catches the ID of the tag and then changes the style of said tag.
I get this error though:
Event thread: click
Error:
name: ReferenceError
message: Statement on line 1: Reference to undefined variable: ChangeIt
Backtrace:
Line 1 of script
ChangeIt("s2");
At unknown location
[statement source code not available]
What am i doing wrong?
Thanks.
The code i am using:
[code=javascript]
ChangeIt(id){
var target = document.getEle mentById(id)
var newColor = "#00ff33"
target.style.co lor = newColor
}
[/code]
The php (this is from withing a while loop):
[php]
echo("<tr bgcolor=".$bgco lor.">
<td id=\"s".$counte r."\" onclick=\"Chang eIt('s".$counte r."');\">\n") ;
echo $counter;
$counter++; //increment counter
echo("</td><td>\n");
echo($row['url']);
echo("</td><td>\n");
echo($row['Util_Uploaded']);
echo("</td></tr>\n");
}
[/php]
I'm trying to get an onclick event where it catches the ID of the tag and then changes the style of said tag.
I get this error though:
Event thread: click
Error:
name: ReferenceError
message: Statement on line 1: Reference to undefined variable: ChangeIt
Backtrace:
Line 1 of script
ChangeIt("s2");
At unknown location
[statement source code not available]
What am i doing wrong?
Thanks.
Comment