SUBROUTINE IMAGEFUNC_A
* Display a simple form, requesting entry of name and age.
* An image is provided, that when clicked, runs a JavaScript
* function to verify that the data is valid. If valid, the
* data is submitted it to the server.
* The image changes when the mouse is pointing to it and
* has clicked it.

*Include the RealWeb definitions
INCLUDE #RW.INCLUDE.DEFS FROM /SYSFILES/REALWEB,BP

* Get the URL of the Reality item server.
IMAGEFILE = ""
CALL RW_GET_PARAM("__isurl", IMAGEFILE)
* Specify the location of the file containing the images.
IMAGEFILE = IMAGEFILE : "/REALWEB-ITEMS/"

* Start the HTML page.
CALL RW_START_HTML_PAGE("Image Function Example", "", "", "", "")

* Get the JavaScript code.
VERIFY = ""
CALL RWA_INSERT_ITEM(VERIFY, "REALWEB-ITEMS", "verify2.js")
* Put the code in the JavaScript buffer.
CALL RW_PUT_EX(VERIFY, RWD_JAVASCRIPT)

FORM = ""

* Create the editboxes.
TEXT = "Name: "
CALL RWA_EDIT_BOX(TEXT, "NAME", 30, "")
CALL RWS_PARA(TEXT, "", "")
FORM = FORM : TEXT

TEXT = "Age: "
CALL RWA_EDIT_BOX(TEXT, "AGE", 10, "")
CALL RWS_PARA(TEXT, "", "")
FORM = FORM : TEXT

*Create an image to act as a submit button.
TEXT = ""
IMAGES = ""
IMAGES<1> = IMAGEFILE : "submit1.gif"
IMAGES<2> = IMAGEFILE : "submit2.gif"
IMAGES<3> = IMAGEFILE : "submit3.gif"
CALL RWA_IMAGE_FUNCTION(TEXT, 'verify();', "Submit", IMAGES, "")
CALL RWS_PARA(TEXT, "", "")
FORM = FORM : TEXT

* Create the HTML form, specifying that the subroutine HELLO
* should be run when the form is submitted.
CALL RWS_FORM(FORM, "HELLO", "FORM1", "")

* Output the HTML.
CALL RW_PUT(FORM)

* Complete the page.
CALL RW_END_PAGE
RETURN

Go to top button