Link to home
Start Free TrialLog in
Avatar of gingerdeb
gingerdebFlag for Australia

asked on

Question for CRAK

In the question below you gave some very good advice regarding how to avoid users submitting forms more than once and creating duplicates:

https://www.experts-exchange.com/questions/20412553/Disable-BACK-Button-After-Submitting-a-Form.html

You mentioned, however, that you also have a "refresh on keyword change"-safe solution.

Can you provide me with that solution?

Thanks,

Deb
Avatar of CRAK
CRAK
Flag of Netherlands image

Sure....
Haven't got it with me right now, but I'll post it a.s.a.p.

How do we make sure Sno doesn't hike along on on your expense?  ;-))
(Just kidding bro!)
Avatar of snocross
snocross

Yes please post this.  I will not listen.
ASKER CERTIFIED SOLUTION
Avatar of CRAK
CRAK
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ahh, I remember that now.  I can't use that for some of my apps because in my $$Return I return a parameter which tells the $$ViewTemplate which special message to display such as 'thank you your deal has been successfully submitted' or 'your deal will go on hold' or whatever.  If I use the history to go back I don't think I can customize that.  But anyway this is not my question and I am not supposed to be listening so I will shut up.
Is this when I'm supposed to say "thanks"???
;-))
Avatar of gingerdeb

ASKER

Thanks guys.

Deb
Glad I can be so helpful!  ;-)
Thanks....
I'll post my "old" solution here as well when/if I find it....
My old solutio appears to be a pop-up thing: a simple bit of javascript: window.open(...).
I'm now trying to solve the problem in a single window.
So far I'm able to jump the right amount of steps back to the view and refresh that it (so show the new doc). Trouble now is not "how to disable back" but "how to disable forward": the new url gets inserted right in the middle of the history! If I'd click on a link myself, that "forward history" would get dropped automatically, but if I do so in javascript..... sigh.....
Will let you know!
Thanks...

Deb
Deb / Sno,
Here's how to do it:

1:
I need to be able to store a variable in a place that does not get overwritten when a new page is loaded. I generally use "top" location in a frameset.
So create a frameset, even if it holds only one single frame!
In the body frame (name is not important): load a view "AllDocs", displayed with a $$ViewTemplate.

2:
The view should contain a way to create (compose) a new document.

3:
The $$ViewTemplate contains following HTML/JS on the form (pass thru html; do not put it in JS Header!):
<SCRIPT LANGUAGE="JAVASCRIPT">
if (top.myReloadMarker == "1")
  {
  top.myReloadMarker = "0";
  myUrl = this.location.href
  p = myUrl.indexOf('?')
  if (p<0)
    {
    myUrl = myUrl + "?OpenView"
    }
  p = myUrl.toLowerCase().indexOf('&nohist=')
  if (p<0)
    {
    // NoHist parameter not found
    myUrl = myUrl + "&noHist=1&dummy"
    }
  else
    {
    // NoHist parameter found
    myUrl1 = myUrl.substr(0, p + 8)
    myUrl2 = myUrl.substr(p + 8, myUrl.length)
    p = myUrl2.indexOf('&')
    if (p>0)
      {
      // Trailing parameter available
      myUrl3 = myUrl2.substr(p, myUrl2.length)
      myUrl2 = parseInt(myUrl2.substr(0, p)) + 1
      }
    else
      {
      // No trailing parameters available
      myUrl3 = ""
      myUrl2 = parseInt(myUrl2) + 1
      }
    myUrl = myUrl1 + myUrl2 + myUrl3
    }
  quote = "'"
  myUrl = quote + myUrl + quote
  document.write('<A HREF="Javascript:location.href=' + myUrl + '" ID="clickToClearHistory" onClick="location.assign(' + myUrl + ')">click here</A>')
  clickToClearHistory.fireEvent("onClick")
  }
</SCRIPT>

4:
The form used to create a document with holds:
- a comp. for display field "Query_String_Decoded", formula:
Query_String_Decoded
- an editable radiobutton field (just add some dummy options and select "Refresh fields on keywords change")
- a comp. for display field "$$Return", formula:
"[/" + @ReplaceSubstring(@Subset(@DbName; -1); "\\"; "/") + "/RelocatorForm?ReadForm&Seq="
+ @Text(@TextToNumber("0"+@Left(@Right(Query_String_Decoded; "&Seq=") + "&"; "&")) + 1) + "]"
- a javascript submit action, formula:
top.myReloadMarker = "1";
document.forms[0].submit();
- javascript code (pass thu html):
<script language="javascript">
function nrStepsBack()
{
  return("parseInt(<Computed Value>)")
}
</script>
<Computed Value> holds following formula:
@Text(@TextToNumber("-0"+@Left(@Right(Query_String_Decoded; "&Seq=") + "&"; "&")) - 1)

5:
A form called "RelocatorForm" (referred to from $$Return).
- in JS Header:
function getSeq()
{
myUrl = this.location.href.toLowerCase()
p = myUrl.indexOf('&seq=') + 5
myUrl = myUrl.substr(p, myUrl.length) + '&'
p = myUrl.indexOf('&')
myUrl = myUrl.substr(0, p)
return(myUrl)
}
- in onLoad event:
top.history.go(-1 * getSeq())


Step 3 holds a JS method "fireEvent". That restricts you to using MSIE 5.5 or higher!
I hope to find a NN compatible solution, but don't think it's worth holding your breath for!

Please put it to test... hope I haven't forgotten anything! ;-))
Excellent work, thanks.
...and JS experts still say it's impossible!
All it takes is a Notes guru, right?
A Notes genius from the beautiful land of Nethers.
Don't go soft sno!
By the way, have you seen that movie (it's a sequential too!) about that weird know-all type riding his bike across the desert to declare war on some lunatic? In the end some nice guy from a small coutry starts working is arse off to solve the biker's problems and make the world a better place. It always ends when the biker donates 500 point grade A to express gratitude....
That does not sound like a good movie.  Sounds like fiction.
By the way I don't have any points so stop begging like Arun.  I don't have thousands to spend like you guys.  ;-)
Who said I was begging?

(100pt? As in the crappy soap version?)

GRIN