Trying to get HTML button to change field value in ConfiForms form

Kevin Kott September 10, 2024

Hello,

I am trying to utilize HTML and javascript to place an HTML button within my confiforms forms and have it able to set a field in the background upon being clicked. I was using

 

https://wiki.vertuna.com/display/TEST/Using+ConfiForms+Field+Definition+rules+with+JavaScript+action+to+get+and+set+field+values

and I am able to have a checkbox group execute javascript, but I am running into a roadblock when having an HTML button run the javascript and set a confiforms field value. In the example above, the FormName and FormId are both passed to the javascript via the field and a field definition rule. So my question here is, how would I pass the FormName and FormId to the HTML button so that it is able to read and write to the form upon being pressed?

1 answer

0 votes
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2024

Hi @Kevin Kott 

Are you injecting your own HTML button with a ConfiForms form that has a custom layout?

In this case there is nothing to do with field definition rules, but you need to set an onclick handler on your button yourself

Alex

Kevin Kott September 10, 2024

I actually have very little Javascript or HTML experience. I am using the HTML macro and using 

<button type="button" onclick="incCounter()">Increment</button>

within the Form View (Registration) macro. I will have to do some research on implementing an onclick handler.

Thanks!

Edit: I was passing the formName and formId values within the onclick handler above but was not getting any change to the confiforms field. My assumption was that formName and formId are undefined within the incCounter() function. Wasn't sure how to define them, how to find the values for them, or if the values are constant every time the form is used.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2024

Who and when should "click" on this button? a user? And what this button is supposed to do? Something with a form?

Kevin Kott September 10, 2024

So, this is an addition to another question I asked. The button is an "import" button. It is just to execute a whole bunch of rules by changing a placeholder field from false to true. I have a multi-select page field that users are choosing multiple pages to pull properties from. But rules do not execute unless a different field is changed. For the sake of a clean looking form, I was trying to implement an html button that "imports" this data after the pages are selected.

To implement this, I created a placeholder checkbox field that the html button will set to true when clicked. Once it's set to true a cascade of rules will be executed that perform the actions I am trying to get done.

I have been able to get the form to work when using the checkbox within the form itself, but it is a little unsightly compared to an HTML button

edit: the example button I posted above was just an exercise I was doing to see if I could get the formName and formId to pass to the JS function so that I can read and write to the form fields. A simple increment function

edit 2: I'm just trying to use the HTML button as a trigger within confiforms rules for "Name of the field you want to track for changes"

edit 3: I went into inspect and searched for formId, it looks like it is randomly generated upon form creation. So, are there any functions I can call within my javascript to retrieve this variable?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events