Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: OAS: Getting pl/sql variables into Javascript variables..
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
![]() |
![]() |