Home » SQL & PL/SQL » SQL & PL/SQL » Create HTML with htp.formOpen
Create HTML with htp.formOpen [message #359599] Mon, 17 November 2008 09:52 Go to next message
ramtin
Messages: 37
Registered: November 2008
Member
Hi,

I need to create HTML Form with htp.formOpen and also I need to put a name for my Form. Could you please tell how I can create HTML Form with name with htp.formOpen.

Thanks
Re: Create HTML with htp.formOpen [message #359618 is a reply to message #359599] Mon, 17 November 2008 11:27 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
if you know the exact HTML you want to create, it's easier to just use htp.p. Using htp.formOpen etc will make your code more compact, but involves a small learning curve. From what I recall, you'll still need lots of htp.p for your custom HTML anyway. BTW, Orale Application Express makes the PL/SQL toolkit somewhat dated, but it's still lightweight and useful for simple pages. See attachment.
  • Attachment: DEMO_PKG.SQL
    (Size: 9.21KB, Downloaded 563 times)
Re: Create HTML with htp.formOpen [message #359623 is a reply to message #359618] Mon, 17 November 2008 13:09 Go to previous messageGo to next message
ramtin
Messages: 37
Registered: November 2008
Member
Yes I know but htp.formOpen does not have any parameter for Form name!!
Re: Create HTML with htp.formOpen [message #359626 is a reply to message #359623] Mon, 17 November 2008 13:20 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
It's not obvious - you use "cattributes" to enter the form name or other attributes. That's why it's easier to just use htp.p() and print whatever HTML you want...

      HTP.formOpen ('demo_pkg.do_something',cattributes=>'name="my_form"');


1) read the online docs http://download.oracle.com/docs/cd/B14099_19/web.1012/b15896/pshtp.htm#i1007043
2) do a describe on htp
...
procedure formOpen(curl     in varchar2,
                   cmethod  in varchar2 DEFAULT 'POST',
           ctarget  in varchar2 DEFAULT NULL,
           cenctype in varchar2 DEFAULT NULL,
           cattributes in varchar2 DEFAULT NULL);
...

[Updated on: Mon, 17 November 2008 13:32]

Report message to a moderator

Re: Create HTML with htp.formOpen [message #359629 is a reply to message #359626] Mon, 17 November 2008 13:30 Go to previous messageGo to next message
ramtin
Messages: 37
Registered: November 2008
Member
Okay this is my problem which one of those parameters is for Form name.
Re: Create HTML with htp.formOpen [message #359630 is a reply to message #359629] Mon, 17 November 2008 13:32 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
HTP.formOpen ('demo_pkg.do_something',cattributes=>'name="my_form"');
Re: Create HTML with htp.formOpen [message #359633 is a reply to message #359599] Mon, 17 November 2008 13:41 Go to previous messageGo to next message
ramtin
Messages: 37
Registered: November 2008
Member
But my problem is I have to use the following command. Could you please tell me how do you add the form name to this line.

htp.formOpen(curl=>owa_util.get_owa_service_path || 'P_GoodPerson',cattributes=>'onSubmit=" return CheckRField(this.name);"');

Thanks
Re: Create HTML with htp.formOpen [message #359634 is a reply to message #359633] Mon, 17 November 2008 13:54 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
Well, the PL/SQL is all on the server side and it looks like you have a call to some browser javascript to give the form name? If so, then you'll need to pass the resulting form name to the called procedure during your GET/POST.
Re: Create HTML with htp.formOpen [message #359636 is a reply to message #359599] Mon, 17 November 2008 14:32 Go to previous messageGo to next message
ramtin
Messages: 37
Registered: November 2008
Member
Yes I need to pass Form name to javascript. Could you please explain more about it.
Re: Create HTML with htp.formOpen [message #359640 is a reply to message #359636] Mon, 17 November 2008 15:37 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
http://www.google.com/search?q=htp%2eformOpen+cattributes+onSubmit
Re: Create HTML with htp.formOpen [message #359922 is a reply to message #359640] Tue, 18 November 2008 18:06 Go to previous messageGo to next message
ramtin
Messages: 37
Registered: November 2008
Member
I need to pass Form name to javascript function. I am createing HTML form with htp.formOpen but does have Form Name parameter. How can I find the Form Name? Could you please give some information about that.

Thank you in advance
Re: Create HTML with htp.formOpen [message #360072 is a reply to message #359599] Wed, 19 November 2008 07:56 Go to previous messageGo to next message
ramtin
Messages: 37
Registered: November 2008
Member
Thanks for your information. I found out how to create form with name as below:

htp.formOpen('yzhkegrt.P_Redpage',
cattributes=>'name="redform" ' || 'onSubmit=" return MField();"');

And that was working find but suddenly stop working, my mean it looks like the MField() is not calling any more. Please advice.

Thanks
Re: Create HTML with htp.formOpen [message #360109 is a reply to message #360072] Wed, 19 November 2008 11:38 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
Simply decide what you want the resultant HTML page containing the form to look like, then use htp.formOpen or htp.p to create the html you want.


htp.formOpen('yzhkegrt.P_Redpage',
cattributes=>'name="redform" ' || 'onSubmit=" return MField();"'); 

is exactly same as:

htp.p('<FORM ACTION="yzhkegrt.P_Redpage" METHOD="POST" name="redform" onSubmit=" return MField();">');




htp.formOpen simply calls htf.formOpen (where htp package contains procedures, and htf package contains functions)
procedure formOpen(curl     in varchar2,
                   cmethod  in varchar2 DEFAULT 'POST',
           ctarget  in varchar2 DEFAULT NULL,
           cenctype in varchar2 DEFAULT NULL,
           cattributes in varchar2 DEFAULT NULL) is
begin p(htf.formOpen(curl,cmethod,ctarget,cenctype,cattributes)); end;



and the htf.formOpen function is simply:

function formOpen(curl in varchar2,
                  cmethod  in varchar2 DEFAULT 'POST',
          ctarget  in varchar2 DEFAULT NULL,
          cenctype in varchar2 DEFAULT NULL,
          cattributes in varchar2 DEFAULT NULL) return varchar2 is
begin return('<FORM ACTION="'||curl||'" METHOD="'||cmethod||'"'||
        IFNOTNULL(ctarget,' TARGET="'||ctarget||'"')||
        IFNOTNULL(cenctype,' ENCTYPE="'||cenctype||'"')||
        IFNOTNULL(cattributes,' '||cattributes)||
        '>'); end;


Re: Create HTML with htp.formOpen [message #360132 is a reply to message #359599] Wed, 19 November 2008 13:06 Go to previous messageGo to next message
ramtin
Messages: 37
Registered: November 2008
Member
Sorry I am looking for the reason that makes javaScript stop working. Do you have any idea about this??

Thanks
Re: Create HTML with htp.formOpen [message #360135 is a reply to message #360132] Wed, 19 November 2008 13:34 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
No idea why it's stopped working. you'll need to either do it the hard way (inspect the resultant HTML form page manually to see what's wrong) or use Firefox with firebug plugin to see what's going on with the the javascript/html.


Re: Create HTML with htp.formOpen [message #360138 is a reply to message #359599] Wed, 19 November 2008 13:39 Go to previous message
ramtin
Messages: 37
Registered: November 2008
Member
Thank you, I found some thing was worng in function. The Fuuction return flase, so should be not going to next page but it does. please advice
Previous Topic: Using Decode in Where Clause
Next Topic: database trigger
Goto Forum:
  


Current Time: Fri Dec 09 07:59:06 CST 2016

Total time taken to generate the page: 0.08509 seconds