Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » converting <A> to htf.anchor
converting <A> to htf.anchor [message #464188] Tue, 06 July 2010 13:22 Go to next message
rkhatiwala
Messages: 177
Registered: April 2007
Senior Member
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
PL/SQL Release 11.1.0.6.0 - Production
"CORE 11.1.0.6.0 Production"

Hi,

I have
<a id="event_id_1" href="wcl_add_event?" onclick="return addParams(event_id_1')">New event ID 1</a>

I want to use htf.anchor
HTF.ANCHOR (
curl IN VARCHAR2,
ctext IN VARCHAR2,
cname IN VARCHAR2 DEFAULT NULL,
cattributes IN VARCHAR2 DEFAULT NULL)
RETURN VARCHAR2;

htf.anchor('wcl_add_event','New event ID 1',cattributes=>'target="_self" onclick="return addParams(event_id_1)"');

I have javascript function as : function addParams(id)

But its not working.
Where can i specify id=, in htf.anchor ?

How can i do this?
Thanks
Re: converting <A> to htf.anchor [message #464194 is a reply to message #464188] Tue, 06 July 2010 16:59 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
By far the easiest way is to simply use htp.p().
htp.p('<a id="event_id_1" href="wcl_add_event?" onclick="return addParams(event_id_1)">New event ID 1</a>');


If you insist on doing it the difficult way, then pull up the code for HTF using your favorite IDE (like toad) and see the code for that function. There's no magic - htf.anchor simply assembles your input values into an html snippet. The more specific you want your snippet to be, the more it makes sense to just use htp.p procedure (or htf.p function).

...
function anchor(curl        in varchar2,
                ctext       in varchar2 character set any_cs,
                cname       in varchar2 character set any_cs DEFAULT NULL,
                cattributes in varchar2 DEFAULT NULL)
                return varchar2 character set ctext%charset is
begin return(anchor2(curl,
          ctext,
          cname,
          NULL,
          cattributes));
          end;



function anchor2(curl       in varchar2,
                ctext       in varchar2 character set any_cs,
                cname       in varchar2 character set any_cs DEFAULT NULL,
                ctarget     in varchar2 DEFAULT NULL,
                cattributes in varchar2 DEFAULT NULL)
                return varchar2 character set ctext%charset is
    curl_cname_null EXCEPTION;
    l_str varchar2(32767);
begin
    if curl is NULL and cname is NULL then
        l_str := '<!-- ERROR in anchor2 usage, curl and cname cannot be NULL --><A NAME=" "';
        if ctext is not null then
            l_str := l_str||'> '||ctext||' </A';
        end if;
        l_str := l_str||'>';
        return l_str;
    end if;

    if curl is NULL then
        l_str := '<A NAME="'||cname||'"';
        if ctext is not null then
            l_str := l_str||'> '||ctext||' </A';
        end if;
        l_str := l_str||'>';
    else
        l_str := '<A HREF="'||curl||'"';
        if cname is not null then
            l_str := l_str||' NAME="'||cname||'"';
        end if;
        if ctarget is not null then
            l_str := l_str||' TARGET="'||ctarget||'"';
        end if;
        if cattributes is not null then
            l_str := l_str||' '||cattributes;
        end if;
        l_str := l_str||'>'||ctext||'</A>';
    end if;
    return l_str;
end;
...


Previous Topic: apex charts tool tip
Next Topic: help template in apex
Goto Forum:
  


Current Time: Fri Aug 07 04:52:26 CDT 2020