Forum Moderators: open

Message Too Old, No Replies

Function to turn on button

Turn reset button on and refresh the page

         

Adam5000

10:44 pm on Jan 9, 2009 (gmt 0)

10+ Year Member



I've got a piece of code that I'm struggling with.

What I'm trying to do is start with a button on the screen that says "Turn on the reset button."

Then, when I click on it, have it turn off, and have the "Reset" button turn on and appear on the screen.

Then finally, when I click on the reset button, have the page refreshed and have the "Reset" button turn off and the "Turn on the reset button" button turn back on.

Or in other words, what I'm trying to do is make a reset button appear on the screen when I click on the "Turn on the reset button," and then have the reset button refresh the page and put things back the way they were at the start.

Below is the closest I've been able to get.

Help!

<HTML>
<HEAD>
<TITLE>Reset button</TITLE>

<SCRIPT type="text/javascript">

function turn_on_the_reset_button()
{
document.getElementById("turn_on_the_reset_button")
style.cssText.turn_on_the_reset_button="display:none";";

document.getElementById("reset_button")
style.cssText.reset_button="display:block;";
}

</SCRIPT>
</HEAD>

<BODY>

<div id="turn_on_the_reset_button">
<input type="button" onClick="turn_on_the_reset_button();" value="Turn on the reset button">
</div>

<div id="reset_button">
<style.cssText="display:none;" input type="button" onClick="refresh the page";

value="Reset">
</div>

</BODY>
</HTML>

astupidname

4:39 am on Jan 10, 2009 (gmt 0)

10+ Year Member



Be aware that within the code below, you may have to replace the 'or' operators ¦¦ in the javascript if this below does not work if you copy and paste it, as I have in the past experienced problems with this forum changing these to the dashed look and can cause syntax error when you try it out.

<HTML>
<HEAD>
<TITLE>Reset button</TITLE>

<SCRIPT type="text/javascript">

function turn_on_the_reset_button() {
var elem = document.getElementById("turn_on_the_reset_button");
elem.style.display = (elem.style.display == 'block' ¦¦ !elem.style.display) ? 'none' : 'block';

elem = document.getElementById("reset_button");
elem.style.display = (elem.style.display == 'block' ¦¦ !elem.style.display) ? 'none' : 'block';
}

</SCRIPT>
</HEAD>

<BODY>

<div>
<button type="button" id="turn_on_the_reset_button" onclick="turn_on_the_reset_button();" style="display:block;">Turn on the 'refresh' button</button>
</div>

<div>
<button type="button" id="reset_button" onclick="window.location.reload();" style="display:none;">Refresh Page</button>
</div>

</BODY>
</HTML>