onclick to run an internal procedure. Is it possible?

xscottehx

Member
I am creating an online booking system and have almost finised it. I am wanting to add the additional functionality of where there are free timeslots gthe user can just click the time and it will run a progress procedure how will this be done using an onclick event:

<td onclick="code here"></td>

Will it be done using javascript or can 4gl be used to do this?

Any help will be appreciated.
 
Progress runs only server side, so you can't run a progress procedure directly.
With the onclick event however you can make a call to progress to run a procedure without submitting the whole page using javascript.
You don't tell us what the Progress procedure will be doing. But this sounds like you want to use Ajax.
Webguy posted some interesting answers with examples in the webspeed forum regarding ajax and jQuery, you might want to take a look at that.

Casper.
 
ah sorry when the onclick procedure is run it will open an appointment booking page where the user can input the people using the room and the reason, basically all of the booking details. I know it is possible to run a js function or procedure but from what u said before im guessing u cant call a progress run function. If i could do it through javascript that would be fine. so if i have a procedure called create_booking. normally i would:

RUN create_booking

but using onclick="RUN create_booking" obviously wont work. If there is an alternative that delivers the same result that is what i need.
 
You cant really call a progress procedure directly from a link with javascript but you can call a procedure with a link or javascript by reloading the page and passing a value that will initiate your progress procedure when the page reloads.

Here is a very simple example. You should be able to compile this with webspeed and run it. make sure to name the html "test.html".

Optionally, you can get a little fancier and use javascript that does an ajax call to another program that runs your procedure and returns the values which you can load into the dom. This way you dont need to reload the page. This is where nice js libraries like jquery come into play.

Code:
<script language="speedscript">
 def var v-cust-name  as char no-undo.
 def var v-cust-phone as char no-undo.
 def var v-error          as char no-undo.
 
 /* if we are reloading page and passed value
    "acct" is not blank run the procedure */
 if request_method eq "get" and
    trim(get-value("acct")) ne "" then
 do:
    run ip-customer-info (input  trim(get-value("acct")),
                          output v-cust-name,
                          output v-cust-phone,
                          output v-error).
 end.
 /* simple procedure just as an example */
 /*********************************/
 procedure ip-customer-info:
 /*********************************/
 def input  param ip-cust-num      as char  no-undo.
 def output param op-cust-name  as char  no-undo.
 def output param op-cust-phone as char  no-undo.
 def output param op-error          as char  no-undo.
 
 /* this could be ouput of a find etc. */
 assign op-cust-name  = "Widgets Inc."
          op-cust-phone = "321-1234".
 
 /* if there is nothing found or an error
    set an error output. for this example
    we just set error to blank */
 assign op-error = "".
 
 end procedure.
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/URL]">
<html xmlns="[URL]http://www.w3.org/1999/xhtml[/URL]">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>procedure example</title>
<script>
 function CustDetail(acct) {
  window.location.href = 'test.html?acct='+acct;
 }
</script>
</head>
<body>
<a href="#" onclick="CustDetail('1111'); return false;">View customer details for account 1111</a>
<!--WSS if trim(get-value("acct")) ne "" then do: -->
<table border="1">
  <tr>
    <td>Customer Name</td>
    <td>Customer Phone</td>
  </tr>
  <tr>
    <td>`v-cust-name`</td>
    <td>`v-cust-phone`</td>
  </tr>
</table>
<!--WSS end. -->
</body>
</html>
 
Back
Top