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.
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:
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, 2004
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?
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, 2007
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, 2003
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, 2004