Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » Calling JS function in pl/sql process
Calling JS function in pl/sql process [message #190512] Thu, 31 August 2006 02:35 Go to next message
tom01
Messages: 29
Registered: July 2006
Junior Member
Hello!

I have a js function defined in 'HTML Header' :

<script language="JavaScript" type="text/javascript">
function disp_alert()
{
alert("Data is invalid! Correct the data and click CONFIRM again.")
}
</script>

I also have a pl/sql process on this page. I want to call disp_alert function in a following way:

if ... then --call function--
else dbms_output.put_line('...');
end if;

How can I call this js function in 'if'??

Tom
Re: Calling JS function in pl/sql process [message #191297 is a reply to message #190512] Tue, 05 September 2006 10:22 Go to previous message
rigatonip
Messages: 50
Registered: December 2005
Member
You could put another set of script tags in there to call you javascript function. Something like this:

create or replace procedure testit(
  pi_test in varchar2)
is
begin

 htp.p('<html>');
 
   htp.p('<head>');
    htp.p('<script type="text/javascript">');
     htp.p('function disp_alert()');
     htp.p('{');
       htp.p('alert("Data is invalid! Correct the data and click CONFIRM again.")');
     htp.p('}');
    htp.p('</script>');
   htp.p('</head>');
 
   if pi_test = 'Y'
   then
    htp.p('<script type="text/javascript">');
     htp.p('disp_alert();');
    htp.p('</script>');
   else
    htp.p('<p>do something else</p>');
   end if;
 
 htp.p('</html>');

end;


To test it, you'll need to use a URL like this

http://myserver/pls/mydad/testit?pi_test=Y

or

http://myserver/pls/mydad/testit?pi_test=N

PR
Previous Topic: How do I save a record when adding records in a multi-record form
Next Topic: Configuring mod_plsql on UNIX
Goto Forum:
  


Current Time: Thu Mar 28 15:10:36 CDT 2024