spacer
cornerspacercorner
Reply
Occasional Advisor
Tony Tran
Posts: 21
Registered: 05-21-2010
0 Kudos

Assign a URL In Code.

Does anyone know how to assign a URL to a label in code?

Advisor
TKLam
Posts: 13
Registered: 06-03-2010
0 Kudos

Re: Assign a URL In Code.

[ Edited ]

You use use client side java script to change the value of label by using "innerHTML". I believe you can search the 7.6 forum for examples, but here's what I can remember:

var oLabel = document.getElementsByTagName("label");
for (var iLabel=0; iLabel < oLabel.length; iLabel++)
{
if (oLabel[iLabel].id = "label tag name")
{
oLabel[iLabel].innerHTML = "URL Link"
}
}


But with V9 its much easier, I would recommend using a Label field set to "Caluclated" caption type and reference a hidden text field:
Caption = "HTTP://" + local.txtURLAddress;

Occasional Advisor
Tony Tran
Posts: 21
Registered: 05-21-2010
0 Kudos

Re: Assign a URL In Code.

I did as you suggested for V9, but the caption for the label is just a text, not a link. I cannot click on it to open that link.

The label has URL property, and I want to assign that property dynamically.

 

Advisor
TKLam
Posts: 13
Registered: 06-03-2010

Re: Assign a URL In Code.

I've attached a quick solution that I hope help explain it a bit better.

 

URL is built dynamically based on the txtURL field.  You can change it around to see how it works.

Label1 is the calculated label field that is clickable.   You will probably want to add additional tags in there.  (ie open in new windows, window mode, etc)

line spacer line
spacerFollow Metastorm on:
spacer Twitter YouTube Blog iTunes LinkedIn Metastorm Community Central, MC2
spacer Copyright © 2011 OpenText Corporation. All Rights Reserved.spacer About Metastormspacer Privacyspacer Legalspacer Site Mapspacer RSSspacer Contact Us
Microsoft Gold Certified Partner
Powered by Windows Azure
line spacer line