Button on Web to open URL in field

Greetings,

I’ve searched the forums, and tried a number of things but have yet to figure
out the following. Any help is appreciated:

I have a form where a long URL is entered into a field in the client. Instead
of displaying this long URL on the web, I would prefer to have a button display
for the end user. Each document has a different link.

In my mind, this should be as simple as referencing the field which contains
the URL in a Button. However, each time it doesn’t see the value of the field
– rather it tries to open the field name as the URL.

I tried computed text, and buttons.
Here’s some code, where the fieldname is MyLink.

As Computed Text:

@If(@ClientType = “Web”; “{<input type=button value="View Link"
onclick="window.open(MyLink);">]”; “”)

As Button in OnClick with Javascript:
window.open(document.form.MyLink.value)

Thanks in advance for any advice.

Josh

Subject: Button on Web to open URL in field

Try this in your computed text:

@If(@ClientType = “Web”; “input type=button value="View Link"
onclick="window.open('” + MyLink + “');">]”; “”)

Emily.

Subject: RE: Button on Web to open URL in field

Thanks for your response Emily, but I get an @Function “text expected” error with that. Maybe the forum stripped out some of your characters? I tried a few combinations of the “quotes” and plus signs, only to find that it tried to open the fieldname with plus signs around it.

Thanks again for any ideas.

Josh

Subject: Button on Web to open URL in field

Try this in the button instead:

location.href = document.forms[0].MyLink.value;

and of course, the form needs to be in edit mode, check the document source in the browser to make sure that the field MyLink exists.

Subject: RE: Button on Web to open URL in field

Thanks for your reply - is there any way to make this work in read mode? I imagine this is why the code isn’t working, as the end users are not permitted to edit the documents.

Thanks again!

Josh

Subject: Solution

I found an alternate solution using a linked image instead, in case anyone is interested:

MyLinkVar := MyLink;

LinkButton := “<img border="0" src="/” + DbPath_forwardSlash + “/my_link.gif" ALT="My Link">”;

“[” +

“” + LinkButton + “” +

“]”

Thanks for everyone’s suggestions.

Josh