Forums

Checkbox group and Event Switcher don't work properly

giulia72 24 Jul, 2017
Hi
I have a checkbox group and based on multiple choices some fields should appear, but it seems to not work:
only if I select one of the checkbox group option it work.

Is it possible to make visible some fields based on multiple checkbox choices using the built-in Event switcher?

Thanks
Giulia
giulia72 25 Jul, 2017
Hi
Any answer?
just to know if I hafe to find different way
Thanks
GreyHead 25 Jul, 2017
Hi Guilia,

Not with the built in events tab, you'd need to use custom Javascript to do this.

Bob
giulia72 25 Jul, 2017
Do you have any example?
I don't use java script
GreyHead 25 Jul, 2017
Hi Giulia,

What exactly do you need to do? What are the IDs of the elements that are involved?

Bob
giulia72 25 Jul, 2017
I have several products (PcVue, WebVue, Dream Report...):
if the user select PcVue or WebVue (or both) PcVue version number field will appear.
If the the user select Dream Report, Dream report version nember field will appear

Hope it is clear
GreyHead 25 Jul, 2017
Hi Giulia,

No, "exactly" means just that - and 'Dream Report' can't be an element ID as it has a space in it.

What are the IDs of the elements in your form that are involved in these events?

Bob
giulia72 25 Jul, 2017
Indeed they are the name of fields not the ID.

Below the IDs:

CHECKBOX GROUP NAME and ID: solutions
Options:
PcVue = PcVue
WebVue = WebVue
Webscheduler = Webscheduler
TouchVue = TouchVue
Dream Report = Dream Report
Alert = Alert
IntraVUE = IntraVUE
Enterprise Historian = Enterprise Historian
Other = Other

CONDITIONS:
If the user ticks PcVue, WebVue, TouchVue or WebScheduler then following fields should appear (IDs):
pcvue_version
protocol
build_number

If the user ticks Dream Report, IntraVue, Alert or Enterprise Historian then following fields should appear (IDs):
version

If the user ticks other then following fields should appear (IDs):
product_name
version

Is it clear now?
healyhatman 25 Jul, 2017
That seems like something you could do with the Events
https://www.chronoengine.com/forums/posts/t103960/chronoforms-v6-hiding-and-showing-a-text-box-based-on-a-certain-value-in-a-dropdown.html
You just need to make a whole bunch of events, for each option. Or make a custom javascript function to do it.
giulia72 26 Jul, 2017
Please read my post description: in dropdownbox group the Events don't work properly
giulia72 26 Jul, 2017
Hello
Any news?

I would to know if I have to look for a different solution

Thanks
giulia72 27 Jul, 2017
Kindly it is possible to recive an answer (negative or positive) as I need to find a solution or altenrnatives

Thanks
GreyHead 27 Jul, 2017
Hi giulia72,

I built a little test form here. This is using the following JavaScript in a Load JavaScript action with the IDs and options you gave. The logic doesn't work cleanly with a Checkbox group - I suspect that you may need Radio Buttons here.
jQuery(document).ready(function(jQ){
	jQ('#fin-solutions input').on('change', function(){
		var option, option_value, option_checked;
		option = jQ(this);
		option_value = jQ(this).val();
		// console.log(option_value);
		option_checked = jQ(this).prop('checked');
		// console.log(option_checked);

		if ( option_value == 'PcVue' 
				|| option_value == 'WebVue' 
				|| option_value == 'TouchVue' 
				|| option_value == 'WebScheduler' ) {
			if ( option_checked ) {
				jQ('#form-row-pcvue_version').show();
				jQ('#form-row-protocol').show();
				jQ('#form-row-build_number').show();
			} else {
				jQ('#form-row-pcvue_version').hide();
				jQ('#form-row-protocol').hide();
				jQ('#form-row-build_number').hide();
			}
		} else if ( option_value == 'Dream Report' 
				|| option_value == 'IntraVue' 
				|| option_value == 'Alert ' 
				|| option_value == 'Enterprise Historian' ) {
			if ( option_checked ) {
				jQ('#form-row-version').show();
			} else {
				jQ('#form-row-version').hide();
			}
		} else {
			if ( option_checked ) {
				jQ('#form-row-product_name').show();
				jQ('#form-row-version').show();
			} else {
				jQ('#form-row-product_name').hide();
				jQ('#form-row-version').hide();
			}
		}
	});
});

Bob
giulia72 28 Jul, 2017
in your test it seems to work except for Webscheduler (I don't know why as your code seems to be correct.

Where do I have to insert Load javascript ? after HTML render?

I need a checkbox group because the user could select several options
GreyHead 28 Jul, 2017
Hi Guilia72,

I have Webscheduler in the options and WebScheduler in the JavaScript - they both need to match up.

The Load JavaScript action needs to be *before* the HTML (Render form) action.

You'll need to carefully think through which inputs you need to display to have this work with a CheckBox group - the logic I have written from your post may not handle all the combinations correctly.

Bob
giulia72 28 Jul, 2017
Thank you for you effort , but it doesn't work

I'm sorry but I will think about a different solution
This topic is locked and no more replies can be posted.