htp.formsubmit question
bekaertJul 5 2006 — edited Jul 18 2006Dear,
I 'm a beginner in htp and htf packages.
I want to insert 3 values (input by user) into a table when they click on the "submit" button and then refresh the page with the new added content.
My code so far (how to make the submit work ?) :
htp.htmlOpen;
htp.headOpen;
htp.title('Overview');
htp.headClose;
htp.bodyOpen;
htp.formOpen('OVERVIEW.Main','post');
htp.TableOpen(cattributes => 'border="0" width=90%');
htp.TableRowOpen(cattributes => 'BGCOLOR="FFFFFF"');
htp.img('/Manuals/logo_bek_sap_txt.jpg', 'LEFT', 'logo');
htp.TableRowClose;
htp.TableClose;
htp.TableOpen(cattributes => 'border="0" width=800 BGCOLOR="'||tablebgcolor||'"');
htp.TableRowOpen;
htp.TableData(htf.fontOpen(textcolor, fontface, 2)||'Datum'||htf.fontClose
, cattributes=> 'VALIGN="TOP" WIDTH="200"');
htp.TableData(htf.fontOpen(textcolor, fontface, 2)||
htf.formText('p_date', '30', '80', p_user_date)||
htf.fontClose
, cattributes=> 'WIDTH="600"');
htp.TableRowClose;
htp.TableRowOpen;
htp.TableData(htf.fontOpen(textcolor, fontface, 2)||'Gebruiker'||htf.fontClose
, cattributes=> 'VALIGN="TOP" WIDTH="200"');
htp.TableData(htf.fontOpen(textcolor, fontface, 2)||
htf.formText('p_user', '30', '80', p_user_name)||
htf.fontClose
, cattributes=> 'WIDTH="600"');
htp.TableRowClose;
htp.TableRowOpen;
htp.TableData(htf.fontOpen(textcolor, fontface, 2)||'Commentaar'||htf.fontClose
, cattributes=> 'VALIGN="TOP" WIDTH="200"');
htp.TableData(htf.fontOpen(textcolor, fontface, 2)||
htf.formTextAreaOpen('p_comment', '6', '70')||
p_user_comment||
htf.formTextAreaClose||
htf.fontClose
, cattributes=> 'WIDTH="600"');
htp.TableRowClose;
htp.tableClose;
htp.br;
htp.formHidden('p_action');
htp.formSubmit(cvalue => 'Insert', cattributes=>'OnClick="this.form.p_action.value=''INSERT''"');
if p_action = 'INSERT' then
BEGIN
insert into mytable
(ID, SUBJECT, USER_DATE, USER_NAME, USER_COMMENT)
values (1 , 'TEST', p_user_date, p_user_name, p_user_comment );
END;
end if;
htp.formReset;
htp.formClose;
-- Display content of table
-- Printing Headers
htp.hr;
htp.TableOpen(cattributes => 'border="0" width=90%');
htp.TableRowOpen('LEFT', 'TOP', cattributes => 'BGCOLOR="D2D2D2"');
htp.TableData(htf.Bold(htf.fontOpen('BLACK', 'Verdana', 1)||'Date'||htf.fontClose));
htp.TableData(htf.Bold(htf.fontOpen('BLACK', 'Verdana', 1)||'User'||htf.fontClose));
htp.TableData(htf.Bold(htf.fontOpen('BLACK', 'Verdana', 1)||'Comment'||htf.fontClose));
htp.TableRowClose;
-- Printing Details
open c_logging_data;
fetch c_logging_data into r_logging_data;
while c_logging_data%found loop
htp.TableRowOpen('LEFT', 'TOP');
htp.TableData(htf.fontOpen(null, 'Verdana', 1)||r_logging_data.USER_DATE||htf.fontClose);
htp.TableData(htf.fontOpen(null, 'Verdana', 1)||r_logging_data.USER_NAME||htf.fontClose);
htp.TableData(htf.fontOpen(null, 'Verdana', 1)||r_logging_data.USER_COMMENT||htf.fontClose);
htp.TableRowClose;
fetch c_logging_data into r_logging_data;
end loop;
close c_logging_data;
htp.TableClose;
htp.bodyClose;
htp.htmlClose;
Regards & THANKS !!!
Stijn