Im currently trying to program a table such that when you mouse over a cell, it changes color. I include a .js file into my php class then it is called through my index.php.
so index.php makes a $table object
then i call $table->displayTable()
here is that codefunction
displayTable()
{
echo '<table class = "halloween" border = "1">';
echo '<script type = "txt/javascript"> src = "java_script.js"></script>';
echo '<tr>';
foreach($this->columns as $header => $order)
{
echo '<th>';
echo $header;
echo '</th>';
}
for($i = 0; $i < $this->numRows; $i++)
{
echo '<tr>';
foreach($this->data[$i] as $value)
{
echo '<td onmousover = "alert(this)" onmouseout = "ParaOut(this)">';
if($value!="")
echo $value;
else
echo '<input type = "text" name = "information" size = 10>';
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
}
this calls javascript.js which is here
function test(value)
{
alert("boring");
alert(value);
}
var ColorCode = new Array("eof1ee", "d6efff", "646560", "ffffcc", "66ccff", "99\
ffcc", "c0c0c0", "669999");
function ParaOver(CaoPhong)
{
CaoPhong.style.backgroundColor = ColorCode[Math.round(Math.random()*10)];
}
function ParaOut(CaoPhong)
{
CaoPhong.style.backgroundColor = "transparent";
}
and nothing happens. any idea how i can get the cells to change color on mouse over? this is my first week ever programming PHP HTML or JavaScript (for an internship) so any veteran advice would be greatly appreciated
thanks