Tip

Rollover buttons and @formulas

If you ever wanted to create a rollover buttons on your web page, then you probably know that JavaScript code is the only choice you have. But what if you want to have rollover buttons with @formula behind!? Here is how to do it:

If you are reading this tip, then you should know that for the action hotspots (with @formula) Domino generates the _doClick(v, o, t) function. If you look in to the source code of your page then for the action hotspot you will see something like
onClick="return _doClick('e662ee54e6165298852569d7004f3d44/$Body/0.3B2E', this, null)"

So, if we could get the first parameter, then we could reuse it by writing our own _doClick function in the onClick event of our rollover buttons (with the same second and third parameters of course). In other words, on our form we will have the action hotspots that we will hide on web page and use only to retrieve the Domino generated _doClick's first parameter for our own _doClick.
Lets consider an example.

1. On you form create an action hotspot and put some formula behind it.
2. Open the properties for the hotspot and click on the last tab (HTML)
3. In the 'Id' field put some id (for example - ahId01)
4. Using passthru html surround your action hotspot with division tags. Don?t forget to hide it with the style="display:none" as we do not need it to appear on our web page example:
<DIV style="display:none"> .. your action hotspot(s) ... </DIV>

5. Put the following code in to the onLoad event of your form

mystr = new String
document.getElementById('ahId01').getAttribute("onClick"))
mytmp = new String(mystr.slice(editstr.indexOf("'")+1))
mystr = mytmp.slice(0, mytmp.indexOf("'"))

...the purpose of this code is to retrieve the first parameter of the _doClick() function that we will use in our own _doClick for the rollover buttons later on.

6. Now create your rollover buttons. Your code will probably look similar to the following:

<A href="#" onMouseOver="..your onmouseover function.."
onMouseOut="..your onmouseout function.."
onClick="return _doClick(mystr, this, null)"><IMG
SRC=...></A>

Note the first parameter for the _doClick function. As you already guessed, by the time your page is loaded 'mystr' will hold the same value as it was generated by Domino for the action hotspot.

Another advantage of this approach is that later when you need to change your @formula you don't need to worry about anything. Whatever Domino will generate it will always be put in to our "mystr" parameter.

The code works on both IE and Netscape browsers. The only exception for Netscape is that it has to be version 6 (as the earlier versions do not support DOM methods used in this code).

This was first published in July 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.