Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppress Dialog Box with history.go(0)

Status
Not open for further replies.

timmbo

Programmer
Feb 22, 2001
167
US
Hi All,

On my form is a button - clear. When the user clicks the button, javascript is called inititating history.go(0) command. While the screen is re-inititalizing, I get this Dialog box stating: "The page cannot be refreshed without resending the information. Click Retry to send the information again, or click Cancel to return to the page that you were trying to view." How do I suppress this box and reload my page? Or if there is a better way of doing this, that would be great.

Code:
function myClearAll(frmName) {
  //alert("IN myclearAll...");
  history.go(0);
  document.forms[frmName].rptSelection[0].checked = true;
  document.forms[frmName].dateFrom.value = "";
  document.forms[frmName].dateTo.value = "";
  document.forms[frmName].releaseDate.checked = false;
  document.forms[frmName].dateFrom2.value = "";
  document.forms[frmName].dateTo2.value = ""; 
  document.forms[frmName].effectiveDate.checked = false;
  document.forms[frmName].fromAmt.value = "";
  document.forms[frmName].toAmt.value = "";
  document.forms[frmName].amountRange.checked = false;
  document.forms[frmName].recNbrAcct.value = "";
  document.forms[frmName].recAcctNumber.checked = false;
  document.forms[frmName].boxName.value = "";
  document.forms[frmName].individualID.checked = false;
}

TIA,
Tim
 

If you just want to reload the page, try this:

Code:
location.reload(true);

Hope this helps,
Dan



[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Thanks for the help Dan. I used your suggestion but still getting the same dialog box. Any other ideas?!
 
Why are you reloading the page anyway? If you only need to clear the form controls it looks like you're already doing that in the code after history.go(0);. I'm guessing that code doesn't even get executed because the page tries to reload itself first.

If you just want to reset the page back to the values the page had when it originally loaded, you can use the reset() function.

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
[banghead]
 
If you don't care that the values posted will be discarded, you should be able to use this to redirect the page to itself:
Code:
location.href = location.href;
If you want to keep the values that were posted and there isn't that much data being passed, you could change the form method from POST to GET. This will allow you to refresh the page without getting the message, but the data will now appear in the address bar instead and doing so will limit the amount of data that can be sent.

Adam

There's no place like 127.0.0.1
 
That's a good question, kaht. I figured Tim was changing more than just form field values. For example, the background color of a table or something. Then the easiest way to reset everything would be to reload the page. But Tim, kaht is right. If all you want is to just reset the form to its default values, use document.formName.reset().

Adam

There's no place like 127.0.0.1
 
Thanks Kaht for the suggestion. reset() works fine for my controls. But I am dinamically loading some account numbers and reset() does not load them back to the original select box.
 
I got it. I just href'd back on the page. Everything cleared and reset. Thanks again everybody.
 
[purple]You're welcome[/purple]

Adam

There's no place like 127.0.0.1
 
Adam, you've got to bold it otherwise it looks too much like black. You're very welcome.

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top