help with JavaScript in PHWeb screen

Richard Sheehan sheerich@isu.edu
Thu, 28 Jun 2001 10:23:06 -0600


Joe,

That was the exact example I was thinking of, but I didn't readily find
it.

Richard

"Boyle, Joe" wrote:
> 
> Hi all,
> 
> I have included Simon's original document below, I came to this conversation
> late so I hope I haven't got the wrong end of the stick. Search for 'CLEA'
> as this is the designer name that is being mapped.
> 
> ******
> 
> Problem Description
> 
> A technique in the PowerHouse Web Guide passes a Session ID from screen to
> screen, but the value is lost when certain functions are used.  How to
> retain it?
> 
> Solution Description
> 
> Starting with the example from the Powerhouse Web Guide, where an initial
> screen generates a SESSION ID number and passes it to a second screen.
> 
> > SCREEN first HTML
> > TEMPORARY session_ID INTEGER SIZE 4 RESET AT STARTUP
> > FILE sessionid DESIGNER
> > FILE customers
> ...
> > FIELD session_ID
> > PROCEDURE POSTUPDATE
> > BEGIN
> >   LOCK sessionid
> >   GET sessionid SEQUENTIAL
> >   LET next_session_ID = next_session_ID + 1
> >   PUT sessionid
> >   UNLOCK sessionid
> >   LET session_ID = next_session_ID
> >   DEFER LINKSCREEN second PASSING session_ID
> > END
> > BUILD
> 
> And a second screen that receives the SESSION ID by doing an ACCEPT in the
> INITIALIZE procedure.
> 
> > SCREEN second HTML
> > TEMPORARY session_ID INTEGER SIZE 4 RESET AT STARTUP
> > FILE customer_details
> ...
> > FIELD session_ID PREDISPLAY
> > PROCEDURE INITIALIZE
> > BEGIN
> >   ACCEPT session_ID
> > END
> > BUILD
> 
> This is fine, but when a user hits the CLEAR button the second screen all
> the values in the screen are reset, including the session ID.
> 
> One way around this problem is create a designer procedure called CLEA which
> calls itself, passing Session ID.
> 
> > PROCEDURE DESIGNER CLEA NODATA
> > BEGIN
> >   DEFER LINKSCREEN second PASSING session_ID
> > END
> 
> This way all the values are reset, but the Session ID is once again read by
> the ACCEPT in the INITIALIZE procedure.
> 
> The HTML will also have to be changed to ensure that the designer procedure
> is called instead of the usual Clear.  The easiest way to achieve this is to
> simply change the button value from "Clear" to "Clear " - note the
> additional space.
> 
> ?
> <input type="submit" name="PH_ACTION" value="Clear ">
> ?
> 
> This way the default CLEAR action is not called, but the Designer Procedure
> CLEA is.  This relies on the traditional Powerhouse fact that only the first
> four characters of a designer procedure's name are recognised.  The extra
> space is barely noticeable within the HTML once displayed in a browser.
> 
> The default HTML to call the designer procedure CLEA can then deleted:
> 
> ?
> <select size="1" name="PH_DESIGNER">
> <option value=""></option>
> <option value="CLEA">CLEA</option>
> </select>
> <input type="submit" name="PH_ACTION" value="Go">
> ?
> 
> Alternatively, use Javascript to rename the buttons as described in the
> Powerhouse Web guide.
> 
> To retain the session_ID following the user doing a SEARCH, add a Postfind
> procedure to accept it again.
> 
> > PROCEDURE POSTFIND
> > BEGIN
> >   ACCEPT session_ID
> > END
> 
> No change to the HTML is required.
> 
> The ADD and DELETE functions also cause the session_ID to be lost because
> they return a blank form once completed successfully.  In this case, the
> technique to retain the Session ID is basically the same as that for the
> CLEAR function, but first checks in the PREUPDATE procedure whether a record
> as been deleted or is new.  The temporary t_newdel is set accordingly - this
> is necessary because the NEW, DELETED and ALTERED RECORD flags are reset
> within the update procedure.
> 
> > PROCEDURE PREUPDATE
> > BEGIN
> >   IF (NEWRECORD OR DELETEDRECORD) AND ALTEREDRECORD
> >     THEN LET t_newdel = "Y"
> >     ELSE LET t_newdel = "N"
> > END
> 
> In the POSTUPDATE procedure, check whether t_newdel is true, and once again
> cause the screen to call itself, passing the sessionid.
> 
> > PROCEDURE POSTUPDATE
> > BEGIN
> >   IF t_newdel = "Y"
> >     THEN DEFER LINKSCREEN second PASSING t_session
> > END
> 
> This could all be done in the UPDATE procedure, but it is strongly
> recommended to avoid changing the default procedures whenever possible.
> Alternatively it could all be done in the PREUPDATE procedure, but the above
> causes the DEFER LINKSCREEN to execute when the Update procedure completes
> successfully.
> 
> The final Powerhouse Code for the second screen is:
> 
> > SCREEN second HTML
> > TEMPORARY session_ID INTEGER SIZE 4 RESET AT STARTUP
> > TEMPORARY t_newdel CHAR*1 RESET AT STARTUP
> > FILE customer_details
> ...
> > FIELD session_ID PREDISPLAY
> >
> > PROCEDURE INITIALIZE
> > BEGIN
> >   ACCEPT session_ID
> > END
> >
> > PROCEDURE DESIGNER CLEA NODATA
> > BEGIN
> >   DEFER LINKSCREEN second PASSING session_ID
> > END
> >
> > PROCEDURE POSTFIND
> > BEGIN
> >   ACCEPT session_ID
> > END
> >
> > PROCEDURE PREUPDATE
> > BEGIN
> >   IF (NEWRECORD OR DELETEDRECORD) AND ALTEREDRECORD
> >     THEN LET t_newdel = "Y"
> >     ELSE LET t_newdel = "N"
> > END
> >
> > PROCEDURE POSTUPDATE
> > BEGIN
> >   IF t_newdel = "Y"
> >     THEN DEFER LINKSCREEN second PASSING session_ID
> > END
> > BUILD
> 
> regards,
> Joe Boyle.
> 
> -----Original Message-----
> From: Richard Sheehan [mailto:sheerich@isu.edu]
> Sent: 27 June 2001 18:04
> To: Fortin, Jean-Pierre
> Cc: 'Edis, Bob'; 'powerh-l@list.swau.edu'
> Subject: Re: help with JavaScript in PHWeb screen
> 
> I am trying to remember where I've seen this stated before ... in the PH
> Web manual or elsewhere, but I believe a space is only needed for
> designer procedure that would otherwise have the same name as a default
> "action" of a quick screen.  Adding the extra space insures that the
> designer procedure is called, not the default procedure.
> 
> "Fortin, Jean-Pierre" wrote:
> >
> > In the applications I've developed, I had to have a space between the last
> > letter of the designer name and the quote.
> >
> > /JP
> >
> > -----Original Message-----
> > From: Edis, Bob [mailto:bob.edis@fleetpride.com]
> > Sent: Wednesday, June 27, 2001 12:42 PM
> > To: 'powerh-l@list.swau.edu'
> > Subject: RE: help with JavaScript in PHWeb screen
> >
> > Thanks Jean
> >
> > My HTML reference (HomeSite 4.0) does not have <FORM NAME=...> as an
> option.
> > It does show <FORM ID=...> but I tried that and it doesn't work.  At Bob
> D's
> > suggestion I tried using <FORM NAME=...> and now I don't get the
> JavaScript
> > error.  However the button doesn't call the LINKSCREEN as defined in the
> > designer procedure either.
> >
> > Why do I need to put a space after CINV?
> >
> > Regards,
> > Blue
> >
> > -----Original Message-----
> > From: Fortin, Jean-Pierre [mailto:Jean-Pierre.Fortin@cognos.com]
> > Sent: Wednesday, June 27, 2001 11:26 AM
> > To: 'Edis, Bob'; 'powerh-l@list.swau.edu'
> > Subject: RE: help with JavaScript in PHWeb screen
> >
> > You must give a name to your form, as in:
> >
> > <form action="/cgi-bin/phcgi.exe" method="POST" name=form1>
> >
> > Since you are using "form1" in your javascript.
> >
> > Also the UserAction will be:
> >
> >    <input type="button" onclick="UserAction('CINV ')" value="Select
> Specific
> > Invoice">
> >
> > Note the is a blank(space) after the V and the quote.
> >
> > This should resolve your problem.
> >
> > / JP
> >
> > -----Original Message-----
> > From: Edis, Bob [mailto:bob.edis@fleetpride.com]
> > Sent: Wednesday, June 27, 2001 12:12 PM
> > To: 'powerh-l@list.swau.edu'
> > Subject: help with JavaScript in PHWeb screen
> >
> > G'day all
> >
> > Environment:
> > PH Web 2.21D3
> > PH 4GL 8.21D4
> > I.E. 5.0
> > Windows NT 4.0 sp6
> >
> > I am trying to create a button on a PH Web HTML template where the button
> > will trigger a designer procedure.  When I run the template in IE5.0 and
> > click on the resulting button I get this JavaScript error:
> >
> > -------------------------------------------------------
> > A runtime error has occurred.
> >
> > Error: 'self.document.form1.PH_ACTION' is not an object
> > -------------------------------------------------------
> >
> > Anybody know what the problem here is (besides me)?
> >
> > Using the example in the documentation I have I have coded some JavaScript
> > as follows:
> >
> > <script language="JavaScript">
> >  <!--
> >  function UserAction( action )
> >  {
> >   self.document.form1.PH_ACTION.action = action;
> >   self.document.form1.submit();
> >  }
> >  //-->
> > </script>
> > </head>
> > <body bgcolor="grey">
> >
> > <!--PH:RECORD-->
> > <form action="/cgi-bin/phcgi.exe" method="POST">
> >
> > The syntax used to in the body of the form is:
> >
> >    <input type="button" onclick="UserAction('CINV')" value="Select
> Specific
> > Invoice">
> >
> > Regards,
> >
> > Blue
> >
> > = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> > Mailing list: powerh-l@lists.swau.edu
> > Subscribe: "subscribe" in message body to powerh-l-request@lists.swau.edu
> > Unsubscribe: "unsubscribe" in message body to
> > powerh-l-request@lists.swau.edu
> > http://lists.swau.edu/mailman/listinfo/powerh-l
> > This list is closed, thus to post to the list you must be a subscriber.
> >
> > = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> > Mailing list: powerh-l@lists.swau.edu
> > Subscribe: "subscribe" in message body to powerh-l-request@lists.swau.edu
> > Unsubscribe: "unsubscribe" in message body to
> > powerh-l-request@lists.swau.edu
> > http://lists.swau.edu/mailman/listinfo/powerh-l
> > This list is closed, thus to post to the list you must be a subscriber.
> >
> > = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> > Mailing list: powerh-l@lists.swau.edu
> > Subscribe: "subscribe" in message body to powerh-l-request@lists.swau.edu
> > Unsubscribe: "unsubscribe" in message body to
> powerh-l-request@lists.swau.edu
> > http://lists.swau.edu/mailman/listinfo/powerh-l
> > This list is closed, thus to post to the list you must be a subscriber.
> 
> --
> Richard Sheehan,
> Administrative Systems - IT Programmer Analyst Associate
> Idaho State University Computing & Communications
> Campus Box 8037, Pocatello, ID 83209-8037
> Phone: 208.282.3861 - Fax: 208.282.3673
> Email: sheerich@isu.edu
> 
> = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> Mailing list: powerh-l@lists.swau.edu
> Subscribe: "subscribe" in message body to powerh-l-request@lists.swau.edu
> Unsubscribe: "unsubscribe" in message body to
> powerh-l-request@lists.swau.edu
> http://lists.swau.edu/mailman/listinfo/powerh-l
> This list is closed, thus to post to the list you must be a subscriber.

-- 
Richard Sheehan,
Administrative Systems - IT Programmer Analyst Associate
Idaho State University Computing & Communications
Campus Box 8037, Pocatello, ID 83209-8037
Phone: 208.282.3861 - Fax: 208.282.3673
Email: sheerich@isu.edu