Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Add 'title' Attribute to Anchor Tag Created By Stylesheet Javascript Parm.

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Add 'title' Attribute to Anchor Tag Created By Stylesheet Javascript Parm.
 Login/Join
 
Master
posted
Greetings,

I'd like to add a 'tool tip' to a link created by the FOCUS Stylesheet JAVASCRIPT parameter.

I am creating an HTML table:

  
TABLE FILE CAR
PRINT COUNTRY
ON TABLE SET STYLE *
TYPE=DATA, FIELD=COUNTRY,
 JAVASCRIPT=runCAR(COUNTRY), WHEN=COUNTRY EQ 'JAPAN',$
ENDSTYLE
ON TABLE HOLD FORMAT HTMTABLE AS MYPAGE
END
-RUN


And then embedding the table into a HTMLFORM:

  
-HTMLFORM BEGIN
<html>
<head>
<script  language=Javascript>
function runCAR() {
 alert('hello world');
}
</script>
</head>
<BODY>
 !IBI.FIL.MYPAGE;
</body>
</html>
-HTMLFORM END


If I was creating the anchor tag by hand, I would add the 'title' attribute, like this:

  
<A HREF="javascript:runCAR('JAPAN');" title="Hello World">JAPAN</A>


Is there a way to add a title attribute to an anchor tag created by WebFOCUS?

Regards,
Dave
 
Posts: 822 | Registered: April 23, 2003Report This Post
Expert
posted Hide Post
David,

Not exactly, but you could use a little trickery to achieve what you require. Replace your drilldown code with the following.
 JAVASCRIPT=runCAR(COUNTRY ');" title="Hello World"'), WHEN=COUNTRY EQ 'JAPAN',$

I have tested this on 7.1.3 and it does work Smiler but the drilldown doesn't due to a javascript error Frowner

You might be able to play with this further to get what you need?

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Expert
posted Hide Post
Ok, got this to work by extending the code. inclusion within the drilldown code didn't work - it kept dropping the extended stuff - so I placed it into a define instead and not only does the link work but also the title -
DEFINE FILE CAR
  COUNTRY_DRILL/A100 = COUNTRY || ''');"' || ' title="Hello World" x="(''';
END
TABLE FILE CAR
PRINT COUNTRY
      COUNTRY_DRILL NOPRINT
ON TABLE SET STYLE *
TYPE=DATA, FIELD=COUNTRY,
 JAVASCRIPT=runCAR(COUNTRY_DRILL), WHEN=COUNTRY EQ 'JAPAN',$
ENDSTYLE
ON TABLE HOLD FORMAT HTMTABLE AS MYPAGE
END
-RUN
  
-HTMLFORM BEGIN
<html>
<head>
<script  language=Javascript>
function runCAR() {
 alert('hello world');
}
</script>
</head>
<BODY>
 !IBI.FIL.MYPAGE;
</body>
</html>
-HTMLFORM END

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Master
posted Hide Post
Thank you, Tony, for the idea of constructing part of the anchor tag with a DEFINE.

My real situation is a bit more complicated than my example. I am passing many fields from my database to the JavaScript function.

For example:

  
TABLE FILE CAR
PRINT COUNTRY
      CAR
ON TABLE SET STYLE *
TYPE=DATA, FIELD=COUNTRY,
   JAVASCRIPT=runCAR(COUNTRY CAR), WHEN=COUNTRY EQ 'JAPAN',$
ENDSTYLE
ON TABLE HOLD FORMAT HTMTABLE AS MYPAGE
END
-RUN

-HTMLFORM BEGIN
<html>
<head>
<script  language=Javascript>
function runCAR(COUNTRY, CAR) {
 alert('hello ' + COUNTRY + ', you drive a ' + CAR);
}
</script>
</head>
<BODY>
 !IBI.FIL.MYPAGE;
</body>
</html>
-HTMLFORM END
-EXIT


Therefore, if I can, I'd like to avoid constructing my anchor tag.

I wonder if I could name my anchor tag, and then 'set' the title in JavaScript?

Regards,
Dave
 
Posts: 822 | Registered: April 23, 2003Report This Post
Silver Member
posted Hide Post
Ok I have tested this one. It is kind of backhanded but it works.

DEFINE FILE CAR                                              
STARTA/A30 = '<A HREF='||''''||'javascript:RUNCAR("';        
MIDA/A5 = '", "';                                            
FINISHA/A25 = '")'||''''||' TITLE="HELLO WORLD">';           
CLOSEA/A4= '</A>';                                           
CNTRY/A100=IF COUNTRY EQ 'JAPAN' THEN                        
          STARTA|COUNTRY|MIDA|CAR|FINISHA|COUNTRY|CLOSE      
          ELSE COUNTRY;                                      
END                                                          
TABLE FILE CAR                                               
PRINT CNTRY                                                  
      CAR                                                    
-*ON TABLE SET STYLE *                                       
-*TYPE=DATA, FIELD=COUNTRY,                                  
-*JAVASCRIPT=RUNCAR(COUNTRY CAR) , WHEN=COUNTRY EQ 'JAPAN',$ 
-*ENDSTYLE                                                   
ON TABLE PCHOLD FORMAT HTMLABLE AS MYTHING                   
END                                                          
-RUN                                                         
-HTMLFORM BEGIN                                              
<HTML>                                                       
<HEAD>                                                       
<SCRIPT  LANGUAGE=JAVASCRIPT>                                
function RUNCAR(COUNTRY, CAR) {                              
 alert('HELLO ' + COUNTRY + ', YOU DRIVE A ' + CAR);         
}                                                            
</SCRIPT>                                                    
</HEAD>                                                      
<BODY>                                                       
 !IBI.FIL.MYPAGE;                                            
</BODY>                                                      
</HTML>                                                      


7.6.6 Mainframe
7.6.4 Web Focus
Windows

 
Posts: 45 | Location: Gaffney SC | Registered: March 30, 2007Report This Post
Virtuoso
posted Hide Post
If you want to use js, this is a starting point:
TABLE FILE CAR
PRINT COUNTRY
      CAR
COMPUTE TITLE_TEXT/A50 = ('This is a '|CAR)||(' from '| COUNTRY); NOPRINT
ON TABLE SET STYLE *
TYPE=DATA, FIELD=COUNTRY,
   JAVASCRIPT=runCAR(COUNTRY CAR TITLE_TEXT), WHEN=COUNTRY EQ 'JAPAN',$
ENDSTYLE
ON TABLE HOLD FORMAT HTMTABLE AS MYPAGE
END
-RUN

-HTMLFORM BEGIN
<html>
<head>
<script  language=Javascript>
function runCAR(COUNTRY, CAR) {
 alert('hello ' + COUNTRY + ', you drive a ' + CAR);
}
function addTitles(){
var i=0;var s='';var t='';var u='';var p='';var q='';var r='';
// Get an array of all the 'a' tags in the document.
var allAnchor = document.getElementsByTagName("a");
// How many 'a' tags are there
var numAnchors = allAnchor.length;
// Loop through all the a tags
for (i=0;i<numAnchors;++i) {
// get the href within the a tag
 t=allAnchor[i].getAttribute("href");
// if this is not a call to runCAR, ignore
  if (t.indexOf("runCAR") < 1) continue;
// substring the href to get the call to the function
// get start of parameters
 s=t.indexOf("(")+1;
// get end of parameters
 u=t.indexOf(")");
// substring
 p=t.substring(s,u);
// put parameters into array
 q=p.split("'");
// get array length, -2 for start and 0 start
 r=q.length-2;
// add title attribute to anchor as last parameter, item r in array q
  allAnchor[i].setAttribute('title',q[r]);
  }
}
window.onload=addTitles;
</script>
</head>
<body>
 !IBI.FIL.MYPAGE;
</body>
</html>
-HTMLFORM END
-EXIT


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Expert
posted Hide Post
Nice solution Alan, but the title text is being shown (in 7.1.3 using IE6) escaped, so they might want to change the title attribute assignment to -
  allAnchor[i].setAttribute('title',unescape(q[r]));

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
Sometimes we try to kill a fly with a sledgehammer because we cannot see the easy way to do something. This seems like one of those times. Would it not be easier just to handle the entire task in the DEFINE?

DEFINE FILE CAR
COUNTRY_DRILL/A100 =
IF (COUNTRY NE 'JAPAN') THEN COUNTRY ELSE
'<A HREF="java_script:runCAR[''' | COUNTRY | ''');" title="Hello World">' | COUNTRY | '</A>';
END
TABLE FILE CAR
PRINT COUNTRY_DRILL
ON TABLE HOLD FORMAT HTMTABLE AS MYPAGE
END
-RUN

-HTMLFORM BEGIN
<html>
<head>
<script language=Javascript>
function runCAR() {
alert('hello world');
}
</script>
</head>
<BODY>
!IBI.FIL.MYPAGE;
</body>
</html>
-HTMLFORM END

JMHO


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Expert
posted Hide Post
That's true Mickey, but my initial attempt was trying to keep it within the drilldown function itself. Alan's version uses a bit of dynamic HTML via JavaScript and yours uses the old belt and braces approach.

So we've achieved something, and that is to show that there are many ways to crack a nut (kill a fly? skin a cat? peel a prawn?) thereby keeping the mind open to all possibilities.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
Ah Yes Tony.

Should have tested the js a bit, unescape is correct.

And as you say, no one solution is perfect for all, otherwise life would be boring.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Master
posted Hide Post
Thank you for the set attribute technique, Alan B. This meets my requirements exactly; I have already incorporated it into my development code.

Many thanks to the other contributors to this topic. I appreciate you adding to the discussion.




Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
 
Posts: 822 | Registered: April 23, 2003Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Add 'title' Attribute to Anchor Tag Created By Stylesheet Javascript Parm.

Copyright © 1996-2020 Information Builders