ho questo form
<form name="gestione_record" id="gestione_record" method="post" action="#"
onsubmit="">
e vorrei impostare l'onsubmit a mio piacimento
ho trovato questa funzione in rete per aggiungere un evento:
function addEvent(obj,type,fn) {
if (obj.addEventListener) obj.addEventListener(type,fn,false);
else if (obj.attachEvent) {
obj["e"+type+fn] = fn;
obj[type+fn] = function() {obj["e"+type+fn](window.event);}
obj.attachEvent("on"+type, obj[type+fn]);
}
}
allora il problema è questo, se scrivo a mano la form così:
<form name="gestione_record" id="gestione_record" method="post" action="#"
onsubmit="return window.confirm('confermi?');">
cliccando su annulla mi interrompe l'azione del form,
se scrivo:
window.onload = function()
{
addEvent(document.getElementById('gestione_record' ),'submit',return
window.confirm('confermi?');
}
mi esce il messaggio "Confermi?" ma se clicco su annulla non mi interrompe
l'azione del form
ciao a tutti il gruppo