Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

If then multiple conditions, including Next button click

Avatar

Level 4

I just want to use Javascript (action builder has fits over multiple "trigger" conditions).  For previous if/then statements I've just used .rawvalues of radio buttons and checkboxes.  Now, I want the event to happen (navigating to page x) when the next button is clicked AND with a checkbox value of 1.

I know about && to join conditions, I just don't know how to code in a rawvalue for an OK button. 

Is there a clean way to do this?  I don't want to have a dozen Ok buttons occupying the space and becoming visible given a checkbox value. That sounds a bit clunky.  I'd appreciate any help!

1 Accepted Solution

Avatar

Correct answer by
Level 7

Hi,

Buttons don't hold values--you can't assign a value to a button.

You normally place a script on it's click event, some solutions for you would be

  • to have either a hidden field or a formVariable) store whether a click has happened.
  • change an attribute of the button (like the fillColor) when clicked and then have other scripts look for that. A button click event changing fillColor does not cause calculate events to fire, so if you want some script on the calculation event to run in response to a fillColor change, put an

               TextField1.execCalculate(); at the end of the script.

Here's an example:

///////////////////////////////////////////////////////////////////////////////

form1.#subform[0].Button1::click - (FormCalc, client)

    $.fillColor = "255,255,255"          //button click changes its own fillColor

    TextField1.execCalculate()          //then fires the script below

/////////////////////////////////////////////////////////////////////////////

form1.#subform[0].TextField1::calculate - (FormCalc, client)

if(Button1.fillColor == "255,255,255")then  //checks button fillColor

     $ = "yes"                                             //does something

else

     $ = "no"                                             //or does something

endif

/////////////////////////////////////////////////////////////////////////////

Hope this helps!

Stephen

View solution in original post

1 Reply

Avatar

Correct answer by
Level 7

Hi,

Buttons don't hold values--you can't assign a value to a button.

You normally place a script on it's click event, some solutions for you would be

  • to have either a hidden field or a formVariable) store whether a click has happened.
  • change an attribute of the button (like the fillColor) when clicked and then have other scripts look for that. A button click event changing fillColor does not cause calculate events to fire, so if you want some script on the calculation event to run in response to a fillColor change, put an

               TextField1.execCalculate(); at the end of the script.

Here's an example:

///////////////////////////////////////////////////////////////////////////////

form1.#subform[0].Button1::click - (FormCalc, client)

    $.fillColor = "255,255,255"          //button click changes its own fillColor

    TextField1.execCalculate()          //then fires the script below

/////////////////////////////////////////////////////////////////////////////

form1.#subform[0].TextField1::calculate - (FormCalc, client)

if(Button1.fillColor == "255,255,255")then  //checks button fillColor

     $ = "yes"                                             //does something

else

     $ = "no"                                             //or does something

endif

/////////////////////////////////////////////////////////////////////////////

Hope this helps!

Stephen