1

I have an InfoPath Designer form that I created and placed into a Site Page. Now I would like each of the buttons on this form to be able to direct to specified URL. I've tried adding the script below to a Script Editor webpart, but it's not working:

<script>     
document.getElementById("CTRL15_5").addEventListener("mouseup", function(){
window.location='http://www.google.com';
});
</script>

Is there another way to do this? Or something wrong with my code?

2 Answers 2

1

I had a similar requirement. It is possible to create buttons that will open new pages. However, it is CRAZY difficult to do.

I will propose an alternative solution that we ended up doing.

I uploaded images that LOOK like buttons. The images of buttons themselves have links embedded which you can easily do in infopath designer. This solved the requirement.

So basically, in infopath designer, place the button images where you want. Embed hyperlinks on the images, and publish the form.

Let me know if that helps.

UPDATE...

Here is how you do it...

Step 1. Open the desired form in infopath designer.

Step 2. Navigate to the section where you wish to place the buttons.

Step 3. Using the top ribbon, click on the Insert tab, and click on Picture

Step 4. With the picture uploaded, click on the image.

Step 5. In the Insert Tab, click Hyperlink (important that the image is selected)

Step 6. Enter the desired URL.

Step 7. Save and publish the form.

See the below screenshots.

enter image description here

enter image description here

7
  • How did you add the links to them?
    – wahle509
    Commented Jan 30, 2019 at 20:16
  • I will update my response. Commented Jan 30, 2019 at 21:28
  • See my updated message. Commented Jan 30, 2019 at 21:36
  • Okay, so that's all dandy, but I need it to display a value on top of it. When I get the form to enter a hyperlink, there are options to Display Text, but are grayed out. How can I enable this?
    – wahle509
    Commented Jan 30, 2019 at 21:42
  • When you say a value, do you mean text over the images? Like a text to describe the button (image) the user will click on? In my case, we had 6 buttons, so I just created six images of buttons with the specific text on them. So the image was the button including the text. Commented Jan 30, 2019 at 21:47
0

Edit buttons in InfoPath designer for this form.

You can use C# code in InfoPath, here is example with action on button..

You can also dynamically set field Value (like some link). More info HERE:

public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
   // Create XPathNavigator positioned at the root of the main data 
   // source.
   XPathNavigator myNav = this.MainDataSource.CreateNavigator()

   // Select employee field and set value to username.
   myNav.SelectSingleNode("//my:employee",this.NamespaceManager).
      SetValue(System.Environment.UserName);
}

Another Examples here.

or just edit in the Designer values if they are static.

Install VSTA for InfoPath manual.

6
  • Can you elaborate more on what you mean by "edit buttons"?
    – wahle509
    Commented Jan 30, 2019 at 19:52
  • added instructions Commented Jan 30, 2019 at 20:01
  • When trying to add code to my button, it says it requires VSTA, which I am not able to add to my work laptop. Is there any other options or ways around this until I can get that enabled?
    – wahle509
    Commented Jan 30, 2019 at 20:05
  • why you cant install VSTA to your laptop? Commented Jan 30, 2019 at 20:46
  • An admin needs to install or configure settings on employee laptops, which could take who-knows how long...
    – wahle509
    Commented Jan 30, 2019 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.