SIII!!!! Esto ha funcionado!!!
Pero ahora me viene otra duda... obviamente no quiero hacer un solo alert dentro la función, sinó que quiero insertar elementos de formulario dentro del div 'divtor'. En concreto, me gustaría poner el siguiente codigo dentro de la función 'addDivTor':
Código:
function addtordiv(obj)
{
divdest = obj.nextSibling.nextSibling.nextSibling;
iaux = parseInt((divdest.id).substring(6));
//If there was something inside the div, delete it
if (divdest.hasChildNodes())
{
while (divdest.hasChildNodes())
{
divdest.removeChild(divdest.firstChild);
}
}
val = obj.options[obj.options.selectedIndex].value;
txt = document.createTextNode('Start Time: ');
divdest.appendChild(txt);
st = document.createElement('input');
st.name = 'text_field';
st.value = '';
divdest.appendChild(st);
divdest.appendChild(document.createTextNode("\u00a0"));
myImg = document.createElement('img');
myImg.src = 'date-icon.gif';
myImg.width = 18;
myImg.height = 18;
myImg.border = 0;
myImg.alt = 'Pick a date';
divdest.appendChild(myImg);
}
donde obj es el elemento que ha provocado el event (en este caso el combobox), pero resulta que claro, me dice que obj no está definido... Como puedo acceder al objeto que lanza el evento???
muchas gracias!