Adding an hyperlink or a button in a form

rss

Posted by ninkasi - May 21 ’13 at 07:49

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

  • Dmitry
    Dmitry
    Admin
    Member for: 7 years 2 months 8 days
    #1 by Dmitry May 21 ’13 at 01:34

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

    $('#fd_form').prepend('<a href="http://test.org">Test</a>');

    Put this script into JavaScript editor in Forms Designer.

  • ninkasi
    Member
    Member for: 6 years 2 months 29 days
    #2 by ninkasi May 22 ’13 at 03:41

    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.

     

  • Dmitry
    Dmitry
    Admin
    Member for: 7 years 2 months 8 days
    #3 by Dmitry May 22 ’13 at 01:05

    [#2]: You can define CSS-class for field or table cell:

    Define CSS class

    Then insert into it your link:

    $('.my-class').prepend('Test');
    
  • Dmitry
    Dmitry
    Admin
    Member for: 7 years 2 months 8 days
    #4 by Dmitry May 22 ’13 at 01:07

    The message was removed by a forum moderator.

  • Dmitry
    Dmitry
    Admin
    Member for: 7 years 2 months 8 days
    #5 by Dmitry May 22 ’13 at 01:10

    [#4]:

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

     

  • ninkasi
    Member
    Member for: 6 years 2 months 29 days
    #6 by ninkasi May 28 ’13 at 04:49

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

     

  • mgilbert
    Member
    Member for: 6 years 2 months 2 days
    #7 by mgilbert Jun 17 ’13 at 09:21

    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.

  • Dmitry
    Dmitry
    Admin
    Member for: 7 years 2 months 8 days
    #8 by Dmitry Jun 17 ’13 at 11:09

    [#7]: 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:

    SharePoint Form Web Parts

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

  • mgilbert
    Member
    Member for: 6 years 2 months 2 days
    #9 by mgilbert Jun 17 ’13 at 01:55

    [#8]: 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!

  • Dmitry
    Dmitry
    Admin
    Member for: 7 years 2 months 8 days
    #10 by Dmitry Jun 17 ’13 at 04:53

    [#9]: 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>.

Displaying 1 to 10 of 20 messages
Previous12