Ticket #190 ( Closed )

Short Description Create JavaScript Info box if TEDATA = "Not Found"
Entered By: Michael - Charleston When: 1998-10-22 16:49:44 Build: 1.03.19d
Categories Type: Question   Department: Product   Category: SurferScript
Description
Basically, when you perform a search on the mainframe that results in no matches, you get the same exact screen (with your input fields cleared) except the message "No Records Found" appears on the lower right of the screen.

What I'm interested in doing with Screensurfer is, when a search is unsuccessful, a JavaScript info box will pop up stating "No records found - please try changing the parameters ... etc." and when the user clicks "OK" they get the Search Form with the values they input still intact.

I was thinking of including a TEIF statement within the TESECTION that defines that screen, but I don't know how to proceed from there ... any suggestions?

Thanks!

Append By: WindSurfer  When: 1998-10-22 17:56:49  New Status: Pending Customer
Comment Use a TEIF and the Screen() function to compare that screen location to "No records found" and if it is there, you can use the trick of calling TEACTION WEBTOSCREEN, as this will copy the users original entries back into the fields the way they were (!).

Then, code the JavaScript function (inside maybe the same or an identical TEIF) like:

function userLoadScript(cursorpos)
{
  alert("No records found- please try changing and try again");
}
When you name a function "userLoadScript", it is called automatically by the TEMACRO TERMBODY tag, which generates an onLoad event calling an internal Screensurfer function that then will check to see if the userLoadScript function exists and calls it if so.
Append By: Michael - Charleston  When: 1998-10-23 15:15:50  New Status: Pending IE
Comment Got everything working except the TEACTION WEBTOSCREEN - it isn't restoring my defaults, most likely because I don't have it defined correctly. I downloaded the new documentation as you suggested in a previous post, but there was still no reference to WEBTOSCREEN anywhere!

So, here's my TEIF statement:

<TEIF (Screen(24,42,21) == "NO RECORDS FOR SEARCH")>
<SCRIPT Language="JavaScript">
<!--Hide from older browsers
function userLoadScript(cursorpos) {
  alert("No records found- please try changing and try again");
}
// end of Script -->
</SCRIPT>
<TEACTION WEBTOSCREEN>
</TEIF>

Also, I had to take out the TEMACRO TERMBODY and replace it with my own BODY tag because the SS_SetCursor function automatically tried to set focus to the first input field of the mainframe screen, but that is a hidden field on my form so I kept getting a Javascript error.

Append By: WindSurfer  When: 1998-10-23 15:25:14  New Status: Pending Customer
Comment Oops. Thought there was more to it...we were asked by a customer to make sure that WEBTOSCREEN would only occur once per "hit" so that his logic wouldn't have to protect against that case.

As a result, since there is an automatic WEBTOSCREEN performed as part of the "emulator" request that started your section running, your subsequent WEBTOSCREEN is skipped.

The secret incantation to control the WEBTOSCREEN in this situation is to add the following line right before the WEBTOSCREEN:

<TESET Task.WebWritten="false">
This clears the "auto-don't-do-it-twice" flag so that the WEBTOSCREEN will work.

Sorry about the documentation-- I thought for sure it was in there, but at least it will be in the next batch.

Append By: Michael - Charleston  When: 1998-10-23 15:50:01  New Status: Pending IE
Comment Gave it a shot, but the user-entered input values still are not appearing in the input boxes:

<TEIF (Screen(24,42,21) == "NO RECORDS FOR SEARCH")>
<SCRIPT Language="JavaScript">
<!--Hide from older browsers
function userLoadScript(cursorpos) {
  alert("No records found- please try changing and try again");
}
// end of Script -->
</SCRIPT>
<TESET Task.WebWritten="false">
<TEACTION WEBTOSCREEN>
</TEIF>

....?

Append By: WindSurfer  When: 1998-10-23 17:10:58  New Status: Pending Customer
Comment Sorry, don't know completely what it might be-- is the original screen generated with TEAREA tags? If the http input values aren't of the form f_n_n then the WEBTOSCREEN won't do anything.

Try doing a <TESHOW web.f_n_n> only substituting the f_n_n with one of the "real" fields that has data in it on the starting form. Also, MAKE SURE that the WEBTOSCREEN is BEFORE any of your TEAREA tags that are displaying the current screen!

Append By: Michael - Charleston  When: 1998-10-26 09:13:35  New Status: Pending IE
Comment Well the good news is - yes, I wasn't using a TEDATA tag but had written out my own INPUT TYPE="TEXT" tag and when I changed it to a TEDATA tag I got the entered value back. Now the bad news - I used my own INPUT TYPE="TEXT" tag because I need to put in my custom onFocus, on Change, and onBlur JavaScript event handlers. So the question is: Is there a way I can insert these event handlers into a TEDATA statement? Alternatively, I tried using the TEDATA tag with the VALUE attribute of the INPUT TAG and that sorta worked except before I enter a value the box shows <B>______</B> and when it displays the value back it's <B>12____</B>. Would there be a way to format this field so that initially it's blank and when there is a value you only have the number without the bolding and underscores?

Or is there yet another way to accomplish this?