Evertjan. wrote:
mscir wrote on 07 nov 2004 in comp.lang.javascript:
very nice examples. I added a bit of code to the 2nd one:
<button onclick="this.disabled=true;this.value='Please Wait...';">click
me once only</button>
Nice idea!
This does work, but it should not, me thinks(...?)
innerHTML seems the way to go.
<button
onclick="this.disabled=true;this.innerHTML='Please Wait...';">
click me once only</button>
Good point, I found this with google... it discusses both approaches and
their potential problems, and has code to handle more than one browser:
http://www.permadi.com/tutorial/jsInnerHTMLDOM/
Here's an example using that code, it works on my IE 6, Netscape 7.2,
Moz 1.7.3, Firefox 1.0 pr:
<script type="text/javascript">
function replaceButtonText(buttonId, text){
if (document.getElementById) {
var button=document.getElementById(buttonId);
if (button) {
if (button.childNodes[0]) {
button.childNodes[0].nodeValue=text;
} else if (button.value) {
button.value=text;
} else { //if (button.innerHTML)
button.innerHTML=text;
}
}
}
}
</script>
<button id="b1" onclick="replaceButtonText('b1', 'Please Wait
1...');">click me once only</button>
<br>
<button id="b2" onclick="replaceButtonText('b2', 'Please Wait
2...');">click me once only</button>
Mike