show/hide textfield in multipageform

Show or hide a text field in a multipage form based on a radio group selection.

Overview

The issue occurs because JavaScript events on the first page do not persist after the form is submitted to load the second page.
Use the built-in field events in ChronoForms on the second page to control visibility, or implement JavaScript within the second page's load event following Semantic-UI framework guidelines.

Answered
em emrahsevgi 23 Dec, 2018
Hi;
I have a multipageform. I am trying to show/hide a text field which is in 2nd page according to 1st page radiogroup. I read https://www.chronoengine.com/faqs/2645-how-can-i-showhide-a-textarea-when-a-checkbox-is-clicked and I preapeared a custom code event on load event (first event) after display_section1 event. My custom code event is like this:
​
<script type="text/javascript">
var checkbox_id, textarea_id, checkbox, textarea, div;
/* edit the next two lines to match the ids of the elements in your form */
checkbox_id = 'tur[0]';
textarea_id = 'myname';

window.addEvent('domready', function() {
checkbox = $(checkbox_id);
textarea = $(textarea_id);
div = $(textarea_id+'_container_div');
div.dissolve();
showHide();
checkbox.addEvent('click', showHide);
});

function showHide() {
if ( checkbox.checked ) {
div.reveal();
textarea.disabled = false;
} else {
div.dissolve();
textarea.value = '';
textarea.disabled = true;
}
}
</script>
​
But this is not work.
​
Thanks for your help.
Gr GreyHead 24 Dec, 2018
1 Likes
Hi emrahsevgi ,
​
Which version of ChronoForms re you using?
​
A multi-page form is normally submitted to the server between pages so your JavaScript will not work, you need to show/hide the text field in the Load event for the second page.
​
Bob
em emrahsevgi 24 Dec, 2018
Hi
​
Thanks for your reply. I am using v6. I understood that I will use javascript on second page. I used javascript on second page after event loader. I used my custom code' s (Javascript code) name instead of event name. But it does not work. I am newbie on chronoform. I can not learn setup sections events at the moment. Does my javascript code work with radiogroup and does my code wrong?
​
thanks
This topic is locked and no more replies can be posted.