0

In Infopath form i have two buttons, when one button is clicked only some fields are to be shown others should be invisible, when another button is clicked other fields only be visible. I get it only some conditional values are set using formatting condition.

How come i get it when buttons are clicked

2

Place all the controls in a section and apply rules on the button click. You can show and hide the default fields and based on button click show and hide the relevant section.

Hide and show sections

Hide sections in InfoPath forms

| improve this answer | |
1

I know this is an old thread, but it was one of the only search results, so I'm going to put in how to do it.

Make a picture button, text box and section.

Section Rules: text box doesn't equal 2, formatting, hide this control

Picture Button Rules:

  1. text box is blank OR text box = 3, Action, Set field's value: text box = 2
  2. text box = 2, Action, Set field's value: text box = 3

The text box does not need to be present on the form.

What this does is it creates a loop and allows for multiple clicking. So when you click on the button the text box says 2 and section will show. When you click again the text box will say 3 and the section will hide.

After applying rule 1., you need to check the box "Don't run remaining rules...". If you don't check this box, it will not loop.

| improve this answer | |
  • It worked for me.Thank you so much for posting this Brittany – Sai Jun 11 '19 at 17:23
1

This is my solution in case you'll want to hide or show sections, which mimics an ajax call without a page refresh similar to the ones you'll find in a React or Angular SPAs, sort of a navbar within infopath.

  1. Create 3 buttons (button1, button2, button3)

  2. Create 3 Sections containing any unique content you want , so you can see results

  3. Create 3 textfields with numneric values and give them default values such as:

        Part1 = default value of 1 , let's call it part1State = 1
        Part2 = default value of 0 , let's call it part2State = 0
        Part3 = default value of 0 , let's call it part3State = 0
    
  4. Section Rules:

     Section 1:
        Type: Formatting, Condition: part1State=0, HIDE THIS CONTROL
     Section 2:
        Type: Formatting, Condition: part2State=0, HIDE THIS CONTROL
     Section 3:
        Type: Formatting, Condition: part3State=0, HIDE THIS CONTROL
    
  5. Button Rules ( no condition for any of them)

    Button 1:
         Type: Action, Set a fields value part1State=1
         Type: Action, Set a fields value part2State=0
         Type: Action, Set a fields value part3State=0
    Button 2:
         Type: Action, Set a fields value part1State=0
         Type: Action, Set a fields value part2State=1
         Type: Action, Set a fields value part3State=0
    Button 3:
         Type: Action, Set a fields value part1State=0
         Type: Action, Set a fields value part2State=0
         Type: Action, Set a fields value part3State=1
    
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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