Adding an hyperlink or a button in a form

Discussions about Forms Designer for SharePoint 2010.
ninkasi
Posts: 9
Joined: Sun Apr 14, 2013

21 May 2013

Hello,

I was wondering if there's a way to add an hyperlink or a button that redirect to an url in a form ?

Does anyone got any ideas ?

Thanx

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

21 May 2013

You can add hyperlink or button with javascript. In the following example I'm adding a hyperlink 'Test' at the top of the form

Code: Select all

$('#fd_form').prepend('<a href="http://test.org">Test</a>');
Put this script into JavaScript editor in Forms Designer.

ninkasi
Posts: 9
Joined: Sun Apr 14, 2013

22 May 2013

Thanks a lot for your answer.

And if I want to place it in a specific table or table cell, is there a way to achieve that ?

I guess I have to declare a div id at some point that the script will refer to, but I didn't find how to do that.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

22 May 2013

You can define CSS-class for field or table cell:

Image

Define CSS class

Then insert into it your link:

$('.my-class').prepend('Test');

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

22 May 2013

Code: Select all

$('.my-class').prepend('<a href="http://test.org">Test</a>);

ninkasi
Posts: 9
Joined: Sun Apr 14, 2013

28 May 2013

Thanks again for your quick answer, I was on the right way but was mistaken # and . !

mgilbert
Posts: 2
Joined: Sun Jun 16, 2013

17 Jun 2013

Hi - I have tried to insert a link and am having trouble. When I add the js code [$('#fd_form').prepend('<a href="http://www.google.com">Google</a>');], save it, and open a new item form all I see is this text at the top of the form: <a href="http://www.google.com">Google</a>. What am I doing wrong? I am using SharePoint 2010 with IE9 - which I beleive is IE8 as SharePoinit 2010 converts to it. I ideally would like to have a link next to a field in a tab, but am starting with the basics. Any hep would be great. Thanks.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

17 Jun 2013

Hello,

I have tried this code in all versions of IE and it seems it works correctly. I suppose you use an old version of Forms Designer. In version 1.x this code is not working. So, if you use Forms Designer 1.x try to open your form as web part page:

Image

Then insert Content Editor Web Part and put your link with help of it.

mgilbert
Posts: 2
Joined: Sun Jun 16, 2013

17 Jun 2013

You are right I do have the older form and have tried your solution and have not been able to get it to work. I inserted the content editor webpart on the new form page and added the js code with the opening and closing javascript tag like this <script type="text/javascript">$('#fd_form').prepend('<a href="http://www.google.com">Google</a>');</script> inside of the html markup, and still nothing. Any other ideas? Thanks!

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

17 Jun 2013

You do not have to use js-code, just put your link into the page with Content Editor Web Part: <a href="http://www.google.com">Google</a>.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests