Topic: putting an event on object row (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=30882" title="Pages that link to Topic: putting an event on object row (Page 1 of 1)" rel="nofollow" >Topic: putting an event on object row <span class="small">(Page 1 of 1)</span>\

 
ricsant
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Feb 2009

posted posted 02-26-2009 16:07

I'd like to do something like that:

oTable = document.getElementById("tabela");

for (var i = 2; i < oTable.rows.length - 1; i++)
{
oRow = oTable.rows[i];

oRow.onmouseover = "this.style.backgroundColor='#FEF7EA';";
}

but the onmouseover event doesn't work, could somebody help me please?

my email to contact is:

ricsant03@gmail.com

many thanks

Ricardo

racerX
Nervous Wreck (II) Inmate

From: Portland Oregon
Insane since: Jun 2006

posted posted 02-26-2009 16:20

I think you're using this but you've used the quotes also. try losing the quotes and see if that works.

code:
<div style="background-color:white; width:100px; height:100px" onMouseover="this.style.backgroundColor='#E2E2E2'" onMouseout="this.style.backgroundColor='white'">This is a div</div>



oTable = document.getElementById("tabela");

for (var i = 2; i < oTable.rows.length - 1; i++)
{
oRow = oTable.rows[i];

oRow.onmouseover = this.style.backgroundColor='#FEF7EA';
}




but I'm not sure if it will work. I'm a noob, but I've played with enough scripts to know the quotes aren't needed unless you're doing it from within a page tag and not in your script

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 02-26-2009 16:35

no, the quotes are necessary.

Do you have an example page that we might have a look at, riscant?

ricsant
Obsessive-Compulsive (I) Inmate

From:
Insane since: Feb 2009

posted posted 02-26-2009 18:18

I got this answer to my question and it worked, take a look:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function colorir(){
tabela=document.getElementById("atabela");
nlinhas=tabela.rows.length;
//alert("Olá "+nlinhas+"")
for(i=0;i<nlinhas;i++)
{
tabela.rows[i].onmouseover=function(){this.style.backgroundColor="#FF0000"}
tabela.rows[i].onmouseout=function(){this.style.backgroundColor="#FFFFFF"}

}
}
</script>
</head>

<body onload="colorir()">
<table width="200" border="1" id="atabela">
<tr>
<td>Linha1</td>
</tr>
<tr>
<td>Linha2</td>
</tr>
<tr>
<td>Linha3</td>
</tr>
<tr>
<td>Linha4</td>
</tr>
<tr>
<td>Linha5</td>
</tr>
</table>
<!--<a href="java script:qtd()">Quantas linhas?</a>-->
</body>
</html>

coach
Nervous Wreck (II) Inmate

From:
Insane since: May 2011

posted posted 05-31-2011 11:10
Edit TP: spam removed


Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu