Form Builder - Is this even possible?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
sandaha
Forum Members
Forum Members
Posts: 23
Joined: Thu Jul 05, 2012 2:11 am

Form Builder - Is this even possible?

Post by sandaha »

I've been messing around with Form Builder and everything is working well. However, I have a requirement which is driving me crazy. Let's say I have a form like so:

Text field A
Text field B
Check boxes C, D, E
Text field F
Text field G

Now, what I need to happen is for Text fields F & G to change value depending on which check box the user selects (either C, D or E).

I have searched the forums to see if this has been addressed before but can't see anything. Does anyone have any suggestion or solutions for a feature like this?
TIA
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: Form Builder - Is this even possible?

Post by Jeff »

You can do it with JS/jQuery.

Something like:
$(.checkbox input).onChange( function() {
$(.EandF input).each( this.value(this.value * 1.5) );
});
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm
Location: OH, USA

Re: Form Builder - Is this even possible?

Post by JohnnyB »

I usually handle that using a combination of backend and frontend technologies. The change of text field values that occurs when a checkbox is checked is handled (almost always) using Javascript.

Search for onchange events.

With jQuery, you can do things like:

Code: Select all

$('#the-checkbox-id-or-class').on('click', function() {
			if ( $(this).is(':checked') || $(this).prop("checked") || $(this).attr('checked') ) {
				// do something when it is checked - for example, $('#the-text-input-id').attr('value','the stuff you want to show in the text input');
			} else {
				// do something when it is not checked, like empty the text input... $('#the-text-input-id').attr('value',''); 
			}
		});
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: Form Builder - Is this even possible?

Post by Jo Morg »

sandaha wrote:Now, what I need to happen is for Text fields F & G to change value depending on which check box the user selects (either C, D or E).
Well it depends... if it needs to be visible and to allow people to be able to modify it before form submission the above suggestions are the way to go. If not...
FormBuilder's Help Page wrote:Computed Field. This allows you to embed a computed field in your form. It is not visible to the user until after the form is submitted. It allows you to do simple arithmetic or string concatenation.
... and not so simple too.
HTH
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
sandaha
Forum Members
Forum Members
Posts: 23
Joined: Thu Jul 05, 2012 2:11 am

Re: Form Builder - Is this even possible?

Post by sandaha »

Thanks for the replies guys. Luckily I dodged a bullet this time and this feature won't be necessary after all. I've filed it for future needs.

Cheers
Post Reply

Return to “Modules/Add-Ons”