Ok, voy a tener suerte. Como es el mismo problema, he simplificado el código para que os animéis a ayudarme.
El problema es que no logro sacar la id del segundo elemento
Código javascript
:
Ver original<html>
<head>
<script type="text/javascript">
function Prueba(t, p) {
alert ("Total de Elementos " + t + "\nId del Elemento Seleccionado " +p)
}
function Accion() {
var ref = ["s_1","s_2"];
for (var i = 0; i < ref.length; i++) {
var elemento = document.getElementById(ref[i]);
var valor = ref[i];
var total = ref.length;
var nomevento = "click";
var funcion = function() {
Prueba(total, +this.id.split("_")[1]);
}
if (elemento.attachEvent)
{
var f=function(){
funcion.call(elemento,window.event);
}
elemento.attachEvent('on'+nomevento,f);
return true;
}
else
if (elemento.addEventListener)
{
elemento.addEventListener(nomevento,funcion,false);
return true;
}
else
return false;
}
}
window.onload = Accion;
</script>
</head>
<body>
<div id="s_1">Elemento 1</div>
<div id="s_2">Elemento 2</div>
</body>
</html>
Gracias