Forums

Dynamic content of submit button?

pixelhexe 03 Sep, 2018
Is it possible to change the content / text of the submit button dynamically and how?
​
I am using a hidden field (yes / no) to alter the subject of the emails being sent by form and the email text itself.
But the submit button has only a simple "Content" field and of course it should change the text (for example "register" or "waiting list") BEFORE the form being submitted.
My hope is that the Advanced tab of the submit button is offering a top secret possibility via the "extra attributes"?🙂
​
hidden field: yes -> submit content: register
​
hidden field: no -> submit content: waiting list
​
Or could I use a custom action to "load" the submit text dynamically on form load?
​
Thank you very much in advance from a big chronoforms fan!
healyhatman 04 Sep, 2018
So you can either have it set on load using shortcodes (like {var:phpaction} ), or make a jQuery function to change the text and bind it to the onChange of the hidden field.
pixelhexe 04 Sep, 2018
Answer
Thanks for the hint, healyhatman!
​
I used a custom javascript with enabled "Add inside domready event" (If enabled then the code will be placed inside a JQuery domready event and will run after the page is loaded) and the script is as simple as that:
​
var val = document.myForm.myHiddenField.value;
if(val==0) {
var buttontext = "REGISTER";
}
else if (val==1) {
var buttontext = "WAITING LIST";
}
$("#mybuttonid").text(buttontext);
thankful greetings! :-)
This topic is locked and no more replies can be posted.