If you still want to do this, I discovered a method that appears to work in the console (change highlighted):
Code:
<script type="text/javascript">
var button_beg = '<button id="button" onclick="showhide();">', button_end = '</button>';
var show_button = 'Show captcha', hide_button = 'Hide captcha';
function showhide() {
var div = document.getElementById( "hide_show" );
var showhide = document.getElementById( "showhide" );
if ( div.style.display !== "none" ) {
div.style.display = "none";
button = show_button;
showhide.innerHTML = button_beg + button + button_end;
} else {
div.style.display = "block";
button = hide_button;
showhide.removeChild(document.getElementById('button'));
}
}
function setup_button( status ) {
if ( status == 'show' ) {
button = hide_button;
} else {
button = show_button;
}
var showhide = document.getElementById( "showhide" );
showhide.innerHTML = button_beg + button + button_end;
}
window.onload = function () {
setup_button( 'hide' );
showhide(); // if setup_button is set to 'show' comment this line
}
</script>
I think there are "better ways", but, as I said before, they triggered the form submission before the captcha could be used. If that was due to something you know about, we can maybe work with it. But, for now, if you still want this, I think the above would likely be the way to go.
A variation on this is (also works in the console):
Code:
<script type="text/javascript">
var button_beg = '<button id="button" onclick="showhide();">', button_end = '</button>';
var show_button = 'Show captcha', hide_button = 'Hide captcha';
function showhide() {
var div = document.getElementById( "hide_show" );
var showhide = document.getElementById( "showhide" );
if ( div.style.display !== "none" ) {
div.style.display = "none";
button = show_button;
showhide.innerHTML = button_beg + button + button_end;
} else {
div.style.display = "block";
button = hide_button;
showhide.style.height = showhide.offsetHeight + 'px';
showhide.removeChild(document.getElementById('button'));
}
}
function setup_button( status ) {
if ( status == 'show' ) {
button = hide_button;
} else {
button = show_button;
}
var showhide = document.getElementById( "showhide" );
showhide.innerHTML = button_beg + button + button_end;
}
window.onload = function () {
setup_button( 'hide' );
showhide(); // if setup_button is set to 'show' comment this line
}
</script>
That one preserves the space which the button had occupied.
Bookmarks