cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AVTS
Super User
Super User

switch text input based on Button click

My app having attached screen. On clicking the button, the inputbox value switch the values from 1 to 2 . 

 

AVTS_0-1652687893979.png

 

Example : 

 

If we press Button A then inputbox text change to 2 and we press Button B then inputbox text change to 1.

 

 

Please help as i badly need help on this is to complete. I tried some nested if statement but they are not working .

 

Tried with following formula,

 

TextInput6

default value :

 If(
!IsBlankOrError(var),
var981
)

---------------

 

Button A

OnSelect 

 

UpdateContext({var:"2"}); Reset(TextInput6);

 

----------------

 

Button B

OnSelect 

 

UpdateContext({var981:"1"}); Reset(TextInput6);

 

----------------

 

But unfortunately i do not know where i am going and i am not getting the desired result.

 

 

8 REPLIES 8
WarrenBelz
Super User
Super User

Hi @AVTS ,
Assuming here var981 is the alternative if var is blank - the Default of your Text box - you also do not need to reset it.

Coalesce(var,var981)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

@WarrenBelz thanks for your quick response. Tried with following formula but Button B is not giving the desired results as stated in my issue. Button A click should display with value 1 in Inputbox6 and if Button B click should display with value 2 in Inputbox6.

@AVTS ,

Please see below - I have var981 set as 981

Switch981.gif

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

Very weird. What i am doing wrong here .

 

AVTS_0-1652694611751.png

 

AVTS_1-1652694628187.png

 

 

AVTS_3-1652694724106.png

 

Hi @WarrenBelz  giving me for the leads. I have applied your logic and working fine with following config. 

 

Button B : 

Reset(TextInput6);
UpdateContext({var981:"2"});

Button A : 

 

Reset(TextInput6);
UpdateContext({var981:"1"});

 

TextInput6 :

 

var981

 

 

@AVTS ,

You posted Button B as requiring "1", not "981", so I responded accordingly.

If we press Button A then inputbox text change to 2 and we press Button B then inputbox text change to 1.

I am assuming my solution provided addressed your requirements provided.

Hi @WarrenBelz please guide me to fix the error with Coalesce(var,var981)

 

all three screenshot is given in previous post. Where i am doing wrong.

@

@AVTS ,

Only 3 settings here - also assuming you have set var981 to Blank() (or whatever else you want to display)

var3.pngvar2.pngvar1.png

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,560)