Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: OAS: Getting pl/sql variables into Javascript variables..

Re: OAS: Getting pl/sql variables into Javascript variables..

From: Rudi Demeulenaere <rdm_at_datafront.nospam.be>
Date: Thu, 28 Oct 1999 20:08:59 +0200
Message-ID: <3818913B.4A22319D@datafront.nospam.be>


Steve B wrote:

> I've a slight problem...
>
> I need to store the values of pl/sql variables into javascript variables..
>
> the following code works fine most of the time
>
> snippet of code....
>
> <script language=JavaScript>
>
> var test1 = "'|| l_text ||'";
>
> </script>
>
> However, when the pl/sql variable contains a reserved character, such as an
> apostrophe....there is a failure in javascript...
>
> I was wondering, does anyone have any pl/sql that will 'escape' the pl/sql
> variable in the same way that the javascript escape() funtion works ????

Why not something like
create or replace function javascript_escape (instring varchar2) return varchar2 as
begin
  return replace(instring,'''','"+escape('')+"'); end;

and your JavaScript constructor would contain   var test1 = "'|| javascript_escape(l_text) ||'";

You'll need more complex coding if you need to escape more characters.

</rudi> Received on Thu Oct 28 1999 - 13:08:59 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US