Difference between revisions of "Recital Web Tutorial"

From Recital Documentation Wiki
Jump to: navigation, search
(Simple POST Form)
 
(11 intermediate revisions by one user not shown)
Line 1: Line 1:
 
==Simple POST Form==
 
==Simple POST Form==
 +
Create an input form in your preferred HTML editor, set the form method to '''post''' and the form action to an rsp file.  Save the file in a '''samples''' sub-directory of [[DB_WWWROOT]] (by default, /opt/recital/webroot/recital).
  
Create an input form in your preferred HTML editor, set the form method to '''post''' and the form action to an rsp file:
+
'''example_form.htm:'''
  
 
<code lang="html">
 
<code lang="html">
Line 57: Line 58:
 
</code>
 
</code>
  
Create the form handler rsp file.  This is coded in Recital and the form data can be accessed from the '''_post[]''' dynamic array.  Any '''?''' display commands will be sent to the browser client.
+
Create an rsp wrapper file for the html file in the ''samples'' directory.
  
<code lang="html">
+
'''form_example.rsp:'''
 +
 
 +
<code lang="recital">
 +
<%@ Language=Recital %>
 +
<html>
 +
<head>
 +
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
 +
<title>Recital Web Sample Form</title>
 +
</head>
 +
<%@ include="/samples/example_form.htm" %>
 +
</html>
 +
</code>
 +
 
 +
Create the form handler rsp file in the ''samples'' directory.  This is coded in Recital and the form data can be accessed from the '''_post[]''' dynamic array.  Any '''?''' display commands will be sent to the browser client.  Convert any data types ([[CTOD()]]) before loading the '''post[]''' data into the table.
 +
 
 +
'''handle_it.rsp:'''
 +
 
 +
<code lang="recital">
 
<%
 
<%
 +
_post.start_date = ctod(_post.start_date)
 
open database southwind
 
open database southwind
use example
+
insert into example from name _post
append blank
+
replace ACCOUNT_NO with _post.account_no, TITLE with _post.title, LAST_NAME with _post.last_name,
+
FIRST_NAME with _post.first_name, INITIAL with _post.initial, STREET with _post.street,
+
CITY with _post.city, STATE with _post.state, ZIP with _post.zip, LIMIT with val(_post.limit),
+
BALANCE with val(_post.balance), AVAILABLE with val(_post.available), NOTES with _post.notes,
+
START_DATE with ctod(_post.start_date)
+
 
? "Data updated"
 
? "Data updated"
close data
+
close databases
 
%>
 
%>
 
<body bgcolor="#FFFFFF" text="#000000">
 
<body bgcolor="#FFFFFF" text="#000000">
 
</body>
 
</body>
 
</code>
 
</code>
 +
 +
Run the form:
 +
 +
<pre>
 +
http://myserver:8001/samples/example_form.htm
 +
</pre>
 +
 +
[[Category:Recital Web]]

Latest revision as of 13:02, 22 June 2011

Simple POST Form

Create an input form in your preferred HTML editor, set the form method to post and the form action to an rsp file. Save the file in a samples sub-directory of DB_WWWROOT (by default, /opt/recital/webroot/recital).

example_form.htm:

<html>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="handle_it.rsp">
<p> Account_no: 
<input type="text" name="account_no">
<br>
Title: 
<input type="text" name="title">
<br>
Last_name: 
<input type="text" name="last_name">
<br>
First_name: 
<input type="text" name="first_name">
<br>
Initial: 
<input type="text" name="initial">
<br>
Street: 
<input type="text" name="street">
<br>
City: 
<input type="text" name="city">
<br>
State: 
<input type="text" name="state">
<br>
Zip: 
<input type="text" name="zip">
<br>
Limit: 
<input type="text" name="limit">
<br>
Balance: 
<input type="text" name="balance">
<br>
Available: 
<input type="text" name="available">
<br>
Notes: 
<input type="text" name="notes">
<br>
Start_date: 
<input type="text" name="start_date">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>

Create an rsp wrapper file for the html file in the samples directory.

form_example.rsp:

<%@ Language=Recital %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Recital Web Sample Form</title>
</head>
<%@ include="/samples/example_form.htm" %>
</html>

Create the form handler rsp file in the samples directory. This is coded in Recital and the form data can be accessed from the _post[] dynamic array. Any ? display commands will be sent to the browser client. Convert any data types (CTOD()) before loading the post[] data into the table.

handle_it.rsp:

<%
_post.start_date = ctod(_post.start_date)
open database southwind
insert into example from name _post
? "Data updated"
close databases
%>
<body bgcolor="#FFFFFF" text="#000000">
</body>

Run the form:

http://myserver:8001/samples/example_form.htm