Web Link Question

A web link that is added to a form by a WQO agent is not functioning and it is not apparent why. Here’s some background:

Depending upon a user’s authorities, a link is added to a RichText field on a form by a WQO agent with the following code. (Additional HTML tags such as

appear above and below the RichText field on the form.)

linkBody = “

” + linkName + “

Call rtItem.AppendText( linkBody )

A link created by the above code functions fine. However, if this code is modified to simply include an ‘onClick’ as follows, the link no longer functions.

Dim onClickString As String

onClickString = | onclick=“JavaScript:validateField(document.forms[0]);return false;”|

linkBody = “

” + linkName + “

Call rtItem.AppendText( linkBody )

The ‘onClick’ calls a JSHeader function called ‘validateField’ which properly displays a message if a field is null. However, if the field is not null, the link no longer functions. (The page does not change). If the mouse pointer is passed over the link, a valid URL appears on the gray bar at the bottom of the browser. Here is the JSHeader function:

function validateField( frm ) {

if (frm.FieldName.value ==null )  

{alert('Please enter a valid value.');

}

}

I’d appreciate any ideas why the ‘onClick’ code that was added to the link prevents the link from functioning properly.

Thanks.

Subject: Web Link Question

This may just be a typo in your post, but if it’s like this in your code, could cause the function to not work (and if you look at the JS console in Firefox/Netscape/Mozilla would throw an error):

onClickString = | onclick=“JavaScript:validateField(document.forms[0]);return false;”|

The JavaScript language is case-sensitive, and the use of the javascript directive in an onclick statement should be all lowercase:

onClickString = | onclick=“javascript:validateField(document.forms[0]);return false;”|

Subject: RE: Web Link Question

Esther, changing ‘JavaScript’ to lower case didn’t seem to make a difference in this case. I found that the following code works:

Dim onClickString As String

onClickString = “JavaScript:validateField(document.forms[0]);return false;”

linkBody = “<a href=” + path + “onClick=” + onClickString + “>” + linkName + “”

Call rtItem.AppendText( linkBody )

By the way, I followed your suggestion from a previous post about installing Mozilla Firefox. You’re right - it does provide good debugging capabilities.

Thanks.

Subject: Web Link Question

Try (i’m giving onClickString a value for example):

onClickString=|alert(‘Clicked!’);|

inkBody = || & linkName & ||

Subject: RE: Web Link Question

Peter, it seems that what you’re suggesting would always display a message when the link is clicked. The intent is to only display a message if a field validation fails which is determined in the JSHeader function. The problem I’ve encountered is that by adding the ‘onClick’ to the link (which calls the JSHeader function) the link has stopped functioning. Accordingly, if there is no field validation error, the link does not open another page as it should. It’s not apparent why adding the ‘onClick’ to the link made it no longer functional.

Thanks for your feedback.

Subject: RE: Web Link Question

Shane -

I sometimes read posts too quickly when at work.

From your post =

Dim onClickString As String

onClickString = |onclick=“JavaScript:validateField(document.forms[0]);return false;”|

linkBody = “” + linkName + “

I’m going to give you the benefit of doubt and say that:

path = |“http://www.foobar.com”|

which makes linkbody evaluate to:

LinkName

OK - So what I don’t believe is that you’re building path like that - What I think is that your path is more like

path = “http://www.foobar.com

which makes the link look like this(broken) link:

LinkName

In short - pay attention to how quotes are handled when building strings. My preference is to always use Pipes for strings, as they seem easier for me to count when I must double them to embed in a string.

Subject: RE: Web Link Question

Peter, you were correct about the quotes being the issue. I found that the following code functions as intended:

Dim onClickString As String

onClickString = “JavaScript:validateField(document.forms[0]);return false;”

linkBody = “<a href=” + path + “onClick=” + onClickString + “>” + linkName + “”

Call rtItem.AppendText( linkBody )

Thanks.

Subject: Web Link Question

Stupid question… but can you get your intended results with the following?

Create a Computed For Display (CFD) Text field at the top of your Form.

The CFD formula:

FIELD richtextbodyfield := “” + linkName + “

Now, when you launch this over the web, the CFD triggers like a WQO agent. The reason I suggest this is 1) obviously less overhead as it doesn’t need to call and return the agent to get the content into the RTF, and 2) you can simplify your link by simply building out the RTF contents in Formula language.

Thoughts?

HTH,

-Chris

Chris Toohey

Subject: RE: Web Link Question

Good suggestion Chris, but it probably isn’t suited for this application. For one thing, the link needs to be displayed in any one of various languages. The application accesses a host DB2 database for the correct link name (depending upon the language specified on a user profile) as well as user authorities. The application is primarily a front end for moving data to and from DB2 - it is not a repository for Notes documents. A certain amount of logic needs to execute in accessing DB2, doing lookups, etc., and this seems to be beyond the scope of a formula in a CFD field.