0
votes

I have a question that has been a headache for me for last 2 days. I am developing an application in Oracle APEX 5. The problem is that on one page, I have to generate an HTML form manually, based on some data in a table (Not through form wizard offered in APEX), but when I submit the form, on the next page I am unable to reference the form fields filled on the previous page. Here is my page region code having the form:

/* source-code for a PL/SQL dynamic region */

declare

vc1   varchar2(107);
vc2   varchar2(35);
vc3   varchar2(35);
vc4   varchar2(35);
vc5   varchar2(35);
vc6   varchar2(35);
item_typ varchar2(50);

BEGIN

htp.p ('<form name="page1_form" method="get" action="user_resp.php">');

htp.p ('<div style="font-size:x-small;">');

htp.p ('Email: &nbsp;<input type="text" id="v_email"> &nbsp;');

htp.p ('<br/> <br/>');


select todayq,opt1,opt2,opt3,opt4,opt5,item_type
  into vc1,vc2,vc3,vc4,vc5,vc6,item_typ
  from todaysq
 where dowk = to_number(to_char(sysdate,'D'));

htp.p ('<p id="vc1">' || vc1 || ' </p> <br/>');
IF upper(item_typ) IN ('RADIO','CHECKBOX') THEN
   if vc2 is not null and vc2 != ' ' then 
      htp.p ('&nbsp;<input type="' || item_typ || '" name="ans1"   value="1" id="vc2"> ' || vc2 || ' <br/> '); 
   end if;
   if vc3 is not null and vc3 != ' ' then 
      htp.p ('&nbsp;<input type="' || item_typ || '" name="ans1" value="2" id="vc3"> ' || vc3 || ' <br/> ');
   end if;   
   if vc4 is not null and vc4 != ' ' then    
      htp.p ('&nbsp;<input type="' || item_typ || '" name="ans1" value="4" id="vc4"> ' || vc4 || '<br/> ' );
   end if;
   if vc5 is not null and vc5 != ' ' then 
      htp.p ('&nbsp;<input type="' || item_typ || '" name="ans1" value="3" id="vc5"> ' || vc5 || '<br/> ');
   end if;
   htp.p ('<br/> <br/>');
ELSIF upper(item_typ) IN ('TEXT','PASSWORD','TEXTAREA') THEN 
      htp.p ('&nbsp;1.<input type="' || item_typ || '" name="ans1"   id="vc2" value="' || vc2 || '"> <br/> '); 
      htp.p ('&nbsp;2.<input type="' || item_typ || '" name="ans2" id="vc3" value="' || vc3 || '"> <br/> ');
      htp.p ('&nbsp;3.<input type="' || item_typ || '" name="ans3" id="vc4" value="' || vc4 || '"> <br/> ' );
      htp.p ('<br/> <br/>');
END IF;

htp.p ('<button type="submit"> Submit </button>');

htp.p ('</div>');

htp.p ('</form>');

EXCEPTION

WHEN OTHERS THEN

  htp.p('What is causing you to search for a new job? <br/> <br/>');

  htp.p('&nbsp;<input type="radio" name="ans1" value="1"> Current Salary <br/> ');

  htp.p('&nbsp;<input type="radio" name="ans1" value="2"> Location<br/> ');

  htp.p('&nbsp;<input type="radio" name="ans1" value="4"> Unhappy with Management<br/> ' );

  htp.p('&nbsp;<input type="radio" name="ans1" value="3"> Less Vacations<br/> <br/>');

  htp.p('<button type="submit"> Submit </button>');

  htp.p('</div>');

  htp.p ('</form>');

END;

(I am sorry if the code is not properly format). But here is the problem.... when I click the submit button, I have a PL/SQL process that is intended to insert the values entered on previous form into a table:

/* PL/SQL process code in the 'Page processing' section */

begin

insert into user_opinions

(uemail,tquestion,uanswer)

values (:v_email, :vc1, :v2) ;

end;

But in the result, I always see that a record is inserted with all null values.... meaning that the form fields values are not available to the PL/SQL process in the 'Page processing' section.

Can someone please help me telling how the form fields values can be referenced in session state, so that we can use them in PL/SQL.

Thanks in Advance.

1
oracle apex has a well built builtin forms tool you can check it is capability in developing forms section of Application Express Application Builder User's Guide documentation if you have to use html forms as you do please check address bar of your app when you submit page normally apex transfers data of items as :P18_ROWID:123456 in address bar you should see that :vc1:12345 if you are not able to probably there is a problem on submit of data - Bahadirs
i coudnt understand the following code in your sample htp.p ('<form name="page1_form" method="get" action="user_resp.php">'); as i know apex does not have any relation with php codes. probably your form tries to submit your data to a php page that does not exist on oracle apex - Bahadirs
Hi All, Please ignore the PHP file reference in my code above. I had actually removed it, and the form element has no 'Action' attribute... probably when I pasted code into my question, I took an incorrect version of the script. So, just ignore the line having PHP script reference. My question was for code without php reference. - user2755525
If you're using manual HTML forms in APEX, you're going to have a bad time /southparkreference. I would question why you aren't using the declarative nature of APEX. - Scott
I agree with @ScottWe. What you're doing is flat-out a bad idea. I see no reason why you would need to do this. What's wrong with using apex? Why are you using apex to then not use it?... Instead, why don't you tell about the actual issue you are trying to resolve instead of having us help resolving a solution you came up with? - Tom

1 Answers

0
votes

Use below code to insert value:

begin

insert into user_opinions

(uemail,tquestion,uanswer)

values (:v_email, vc1, vc2) ;

end;