Conditionally send the form data to different endpoints based on user input?

<form id="form1" method="post" is="dmx-serverconnect-form" action="input1.value==1?/api/test/option1:/api/test/option2"> is this code correct?

tried dmx-bind replacing ‘action’ in the code but doesn’t work…is there a possible solution for this??
JB

I’m not exactly sure what you are trying to achieve but if I understand correctly it would likely be a good case to use a Flow. Using the condition … if condition is met then run action 1, else run action 2. Instead of a submit button, add an onClick event to your button and run the flow.

Maybe I’m not understanding what you are trying to do. You may need to provide more details.

1 Like

Yes thanks Brad sort of came to that conclusion just interested to see whether it would be a reasonable approach to conditionally send the form data to different endpoints based on user input.

Yes, you can use a dynamic form action that has a ternary to decide which api endpoint to hit. Your syntax is just off.

Try


<form id="form1" method="post" is="dmx-serverconnect-form" dmx-bind:action="input1.value==1?'/api/test/option1':'/api/test/option2'">

1 Like

Great thanks mebeingken, tried that works fine :slight_smile:

1 Like