Friday, October 26, 2007

javascript form reset()

Today, I am looking at the a problem at form.reset().

I found out form.reset() function suppose to be reset all form objects to original values.

I have problem in this situation :
If I delete an OPTION from a SELECT, reset() function won't recover original item.

I can't find any answers on the web.

Thursday, October 25, 2007

innerText and textContent

Try to use your HTML text/code for your confirm dialog message, below is my sample.



document.getElementById("msg").innerText is perfect for IE, but Firefox.

document.getElementById("msg").textContent works for Firefox, but loses all line breaks.



So I come out my solution :

<div style="display: none; visibility: hidden;" id="msg">
Deleting this category will lose all articles.
Do you really want to do it?</div>

<SCRIPT>
function confirmDeletion() {
var msg = document.getElementById("msg").innerHTML.replace(/
/ig,"\n");
if (confirm(msg) ) {
....
form.submit();
}
return false;
}
</SCRIPT>