Foros del Web » Programando para Internet » Javascript »

Obtener Id de Fila y Columna

Estas en el tema de Obtener Id de Fila y Columna en el foro de Javascript en Foros del Web. Saludos amigos, quiero hacer un juego con javascript, el famoso juego del gato: tengo el siguiente formulario: Código HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...
  #1 (permalink)  
Antiguo 29/10/2007, 15:23
Avatar de ftabilo  
Fecha de Ingreso: junio-2007
Ubicación: En el Pc
Mensajes: 139
Antigüedad: 16 años, 10 meses
Puntos: 3
Obtener Id de Fila y Columna

Saludos amigos, quiero hacer un juego con javascript, el famoso juego del gato:

tengo el siguiente formulario:

Código HTML:
<!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=iso-8859-1" />
<title>GATO</title>
<script language="javascript">
function calcular()
{
	alert("Aqui debería mostrar coordenadas :(")
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<div align="center" style="width:100%">
<br /><br />
<table border="2" cellpadding="1" cellspacing="1" id="mitabla">
<tr id="1">
<td width="102" id="1" style="height:100px;width:100px" onmouseover="calcular()"></td>
<td width="98" id="2" style="height:100px;width:100px"></td>
<td width="100" id="3" style="height:100px;width:100px"></td>
</tr>
<tr id="2">
<td id="1" style="height:100px;width:100px"></td><td id="2" style="height:100px;width:100px"></td><td id="3" style="height:100px;width:100px"></td>
</tr>
<tr id="3">
<td id="1" style="height:100px;width:100px"></td><td id="2" style="height:100px;width:100px"></td><td id="3" style="height:100px;width:100px"></td>
</tr>
</table>
</div>
</form>
</body>
</html> 
Cada fila y cada columna tiene un Id, he buscado en las FAQ`S y en todos lados y no he pillado una forma de leer la fila y la columna (coordenadas), al momento de pasar el puntero encima de una celda, si alguien me ayuda muchisimas gracias.

Hasta Luego
  #2 (permalink)  
Antiguo 29/10/2007, 16:00
 
Fecha de Ingreso: diciembre-2003
Mensajes: 1.583
Antigüedad: 20 años, 4 meses
Puntos: 13
Re: Obtener Id de Fila y Columna

Código HTML:
<!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=iso-8859-1" />
<title>GATO</title>
<script language="javascript">
function calcular(elemento)
{
	alert("ID columna (td):" + elemento.id);
	alert("ID fila (tr):" + elemento.parentNode.id);
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<div align="center" style="width:100%">
<br /><br />
<table border="2" cellpadding="1" cellspacing="1" id="mitabla">
<tr id="1a">
<td width="102" id="1" style="height:100px;width:100px" onmouseover="calcular(this)"></td>
<td width="98" id="2" style="height:100px;width:100px"></td>
<td width="100" id="3" style="height:100px;width:100px"></td>
</tr>
<tr id="2a">
<td id="1" style="height:100px;width:100px"></td><td id="2" style="height:100px;width:100px"></td><td id="3" style="height:100px;width:100px"></td>
</tr>
<tr id="3a">
<td id="1" style="height:100px;width:100px"></td><td id="2" style="height:100px;width:100px"></td><td id="3" style="height:100px;width:100px"></td>
</tr>
</table>
</div>
</form>
</body>
</html> 
Ojo! el atributo ID aplicado a un elemento es único e irrepetible dentro del documento.
__________________
El conocimiento es libre: Movimiento por la Devolución
  #3 (permalink)  
Antiguo 30/10/2007, 11:00
Avatar de ftabilo  
Fecha de Ingreso: junio-2007
Ubicación: En el Pc
Mensajes: 139
Antigüedad: 16 años, 10 meses
Puntos: 3
Re: Obtener Id de Fila y Columna

Gracias frijolerou, me ha sido muy útil tu ayuda.

Saludos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:36.