set define off REM This package contains functions and procedures REM to assist the construction of www-pages. REM Author Harri Laine, 29.1.1999 create or replace package iht2 as procedure add_any_js(js in char, checkList in out varchar2); -- and-concatenates javascript condition js into checklist procedure colored_text(cTextcolor char, cBgColor char, cText char, nWidth integer:=100, nSize integer:=NULL); -- Outputs a text item in boldface style with colored background. -- cTextcolor gives the color of the text in eiher as the name of the -- name of the color (e.g. red, white, blue,...) or as a RGB-value -- (e.g. #FFFFFF) -- cBgColor specifies the background color for the line coded as -- cTextcolor -- cText specifies the text to be printed -- nsize specifes the propotional font size, +I indidate increade of I units -- -I decrease of I units. Thus 1 is default+1 and -- -2 equals to default-2. zero and NULL result in default font. -- cWidth specifies the length of the background block as -- percentage of the width of the page procedure field_print(cPrompt char, cElement in char, cStyle in char:= 'NL_COL2'); -- Generates html-code for positioning the prompt (cprompt) -- of a form field (given in html as celement) as defined by -- the parameter cstyle: -- cstyle='NL_COL2': prompt and field in two successive columns of -- a new row in a table -- cstyle='COL2': prompt and field in two successive columns of -- within a row in a table -- cstyle='COL': field in table column, no prompt -- cstyle='TOP': prompt in small font above the field -- cstyle='TOP_COL': field and prompt in the same column of a -- table, prompt in small font above the field -- cstyle='PRE': prompt, delimiter colon (:) and the field -- prompt_special gives any additional attributes for the prompt -- elem_special gives any additional attributes for element value -- Example: form_field('Nimi:','Value','NL_COL2') procedure form_button(cType char, cValue char, cName char:= null, cStyle char:='COL'); -- Generates a button on the form. ctype ={SUBMIT/RESET} -- defines the type of the button. cvalue determines the text on the -- button. Optinal parameter cname defines the name for the object. -- If cname is not null the program to be called will obtain this -- parameter in a call. The effect of cstyle is defined in procedure -- form_field. procedure form_end; -- Generates the end tag for an html-form. procedure form_date_field(cPrompt char, cName char, cValue char := null, cStyle char := 'NL_COL2'); -- Generates html-code for including a JavaScript -- checked date-field in a form. Date format is DD.MM.YYYY -- and the value must be within range 01.01.1901 - 31.12.2099. -- cprompt is the prompt attached to the field. -- cname is the name of the field. -- cvalue gives the initial value for the field. -- The effect of cstyle is defined in procedure form_field. procedure form_field(cPrompt in char, cElement in char, cStyle in char); -- Generates html-code for positioning the prompt (cprompt) -- of a form field (given in html as celement) as defined by -- the parameter cstyle: -- cstyle='NL_COL2': prompt and field in two successive columns of -- a new row in a table -- cstyle='COL2': prompt and field in two successive columns of -- within a row in a table -- cstyle='COL': field in table column, no prompt -- cstyle='TOP': prompt in small font above the field -- cstyle='TOP_COL': field and prompt in the same column of a -- table, prompt in small font above the field -- cstyle='PRE': prompt, delimiter colon (:) and the field -- -- Example: form_field('Nimi:','','NL_COL2') procedure form_hidden_field(cName char, cValue char); -- inserts a hidden field with the given name and value into -- a html-form. procedure form_menu(cPrompt char, cName char, cOptions char, cSelected char, cStyle char:= 'NL_COL2'); -- Generates code to include a pull-down menu in the form. -- cprompt is the prompt attached to the menu. -- cname is the name of the field. -- options contains a comma separated list of menu -- options. A menu option may contain the visible value and -- the delivered value. Delivered value is optional. If given -- it should succeed the visible value after #-delimiter. -- Example 'VISIBLE1#DELIVERED1,VIS2, VIS3#DEL3'. -- cselected gives the default selection. It is compared -- to the delivered value. -- The effect of cstyle is defined in procedure form_field. procedure form_number_field(cPrompt char, cName char, nSize integer, cValue char:= null, cStyle char:= 'NL_COL2'); -- Generates html-code for including a JavaScript -- checked numeric field in a form. -- nsize specifies the length of the field. -- cprompt is the prompt attached to the field. -- cname is the name of the field. -- cvalue gives the initial value for the field. -- The effect of cstyle is defined in procedure form_field. procedure form_range_field(cPrompt char, cName char, nSize integer, nLower integer, nUpper integer, cvalue char := null, cStyle char:= 'NL_COL2'); -- Generates html-code for including a JavaScript -- checked numeric field in a form. The value of the -- field must be between nlower and nupper. -- nsize specifies the length of the field. -- cprompt is the prompt attached to the field. -- cname is the name of the field. -- cvalue gives the initial value for the field. -- The effect of cstyle is defined in procedure form_field. procedure form_start(cURL in char, cMethod in char:='post', cSubmitCheck in char:=null); -- Generates html-code for starting a form. -- curl gives the URL of the program that will process the -- submitted form. -- cmethod specifies the way to pass the parameters. Alternatives -- are 'post' (thru sysinput) and 'get' (thru environment variable) -- csubmitcheck contains the JavaScript checks to be executed -- before the form is submitted. Procedure add_presence_test can -- be used in construction of csubmitcheck. procedure form_textarea(cPrompt char, cName char, cValue char, nCols int:=40, nRows int:=3, cStyle char:='NL_COL2'); -- Generates code for html textarea. -- ncols is the width of the area and nrows is the height. -- cprompt is the prompt attached to the field. -- cname is the name of the field. -- cvalue gives the initial text. The size of the text must -- be less than 2400 bytes. -- The effect of style is defined in procedure form_field. procedure form_text_field(cPrompt char, cName char, nSize integer, nMaxLength integer, cValue char := null, cStyle char:= 'NL_COL2'); -- Generates html-code for including a normal text field in -- a form. -- nsize specifies the length of the field. -- nmaxlength gives the maximun length of the value. -- cprompt is the prompt attached to the field. -- cname is the name of the field. -- cvalue gives the initial value for the field. -- The effect of style is defined in procedure form_field. procedure form_2_standard_buttons(cSubmit varchar2, cReset varchar2); procedure form_4_standard_buttons; procedure js_allchecks; -- generates javascript code for isEmpty, isNonEmpty, -- isDate, isInRange, isNumeric, dateCheck, numCheck, -- rangeCheck and presenceCheck. procedure js_checksonly; -- generates a javascript block that contains the functions -- generated by js_allchecks. procedure js_functions_start; -- produces javascript block starter tag procedure js_isempty; -- generates code for javascript function isEmpty(textfield) that -- evaluates true if the argument is empty and othervise false. procedure js_datecheck; -- generates code for javascript function dateCheck(textfield) that -- evaluates true if the argument is a valid date between -- 1.1.1901 and 31.12.2099, -- otherwise it evaluates false and produces an error message. procedure js_isdate; -- generates code for javascript function isDate(textfield) that -- evaluates true if the argument is a valid date between -- 1.1.1901 and 31.12.2099 and otherwise false. procedure js_isinrange; -- generates code for javascript function -- isInRange(textfield, lower, upper) that -- evaluates true if the argument is numeric and is between -- lower and upper, otherwice false. procedure js_isnonempty; -- generates code for javascript function isNonEmpty(textfield) that -- evaluates true if the argument is non-empty and othervise false. procedure js_isnumber; -- generates code for javascript function isNumber(textfield) that -- evaluates true if the argument is numeric and othervise false procedure js_numcheck; -- generates code for javascript function numcheck(textfield) that -- evaluates true if the argument is numeric and otherwice -- evaluates to false and produces an error message. procedure js_rangecheck; -- generates code for javascript function -- rangecheck(textfield,lower,upper) that -- evaluates true if the argument is numeric between lower and upper, -- otherwise it evaluates false and produces an error message. procedure page_end( cdate varchar2, csignature varchar2); -- end tags procedure page_start(cTitle in char); -- starts a normal html page, and prints its title. procedure table_end; -- ends a table procedure table_start(cattributes char:=NULL); -- starts a table. cAttributes contain atributes to be included within -- the table tag function text_field(cName char, nSize integer, nMaxLength integer, cValue char , cCheck char) return varchar2; -- produces a html input text item -- cname will be the value of name-attribute -- nsize will be the value of size-attribute -- nmaxlength will be the value of maxlength-attribute -- cvalue will be the value of value-attribute -- ccheck contains text (usually JavaScript) to be included -- within the tag after the previous attributes function value_required(fieldname char) return varchar2; -- gives the javascript function to test if the field 'fieldname' -- has been given a value end; / show errors create or replace package body iht2 as procedure add_any_js(js in char, checkList in out varchar2) is begin if checklist is NULL then checklist:= js; elsif checklist ='' then checklist:= js; else checklist:= checklist||' && '||js; end if; end; function value_required(fieldname char) return varchar2 is nstr varchar2(80); begin nstr:='presencecheck('||fieldname||')'; return nstr; end; procedure colored_text(ctextcolor char, cbgcolor char, ctext char, nwidth integer:=100, nsize integer:=NULL) is incr integer; astr varchar2(200); begin htp.p('
'); incr:=nsize-4; astr:= ''; elsif nsize>0 then astr:= astr||' size="+'||to_char(nsize)||'">'; elsif nsize<0 then astr:=astr||' size="'||to_char(nsize)||'">'; else astr:= astr||'>'; end if; htp.P(astr||ctext||' |