Merging Two Fields in ContentBuilder

  • bazaloo
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0

bazaloo created the topic: Merging Two Fields in ContentBuilder

Where can I find some more information about how to use scripts on fields in contenbuilder. I'm trying to do what I think is a very simple thing: merge two fields into one. Its a user registration form and I want the first name and last name combine to create a "name" value.

I tried this in the init code section of the name field

contentbuilder.onSubmit(
function(){
contentbuilder._('name').value = Number(contentbuilder._('firstname').value) + Number(contentbuilder._('lastname').value);
}
);

Apart from this though I would love to learn more about how to use scripting in contentbuilder
#127963
  • Posts: 7464
  • Karma: 150
  • Thank you received: 553

TheMuffinMan replied the topic: Merging Two Fields in ContentBuilder

Hi,

below is an example, please put it into View Tab => click the field type (for example "text") => Scripts Tab => Init (JS):
contentbuilder.onSubmit(
   function(){
       contentbuilder._('description').value = contentbuilder._('subject').value + ' ' + contentbuilder._('title').value;
       return true;
   }
);

Adjust the code to your requirement. Important is the return true in the end as this tells the form to submit. This gives you some control over the form sending or not, depending on your algorithm.

Regards,
Markus

===============================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
===============================================
Satisfied?
Consider a membership!
===============================================
Like us on Facebook
===============================================
#128076
  • bazaloo
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0

bazaloo replied the topic: Merging Two Fields in ContentBuilder

Very awesome, Markus. That worked perfectly. I really appreciate it.
#128567
  • Posts: 15270
  • Karma: 287
  • Thank you received: 1074

pedro81 replied the topic: Merging Two Fields in ContentBuilder

great!

Let us know if you have further questions.

Regards,
Pedro
=========================================Need to renew Pro Support?
Buy Here!
===============================================
Satisfied?
Consider a membership!
===============================================
Like us on Facebook
===============================================
Follow us on Twitter
==============================================
#128676
  • Posts: 2
  • Thank you received: 0

ultraviolence replied the topic: Merging Two Fields in ContentBuilder

Hi,

i would like to merge 3 fields into one. The new field is called "adresse" und should be populated by the fields "strasse", "plz" and "ort" seperated by ",". I used the code
contentbuilder.onSubmit(
   function(){
       contentbuilder._('adresse').value = contentbuilder._('strasse').value + ', ' + contentbuilder._('plz').value + ', ' + contentbuilder._('ort').value;
       return true;
   }
);

Unfortunately the field "adresse" doesnt get filled, it remains empty. Any hints are appreciated.

Thx in adance
Johnny.
#228160
  • Posts: 46
  • Thank you received: 0

Bibbp replied the topic: Merging Two Fields in ContentBuilder

Did you get an answer?
#234902
Moderators: ForumSupporttomeperica
Time to create page: 0.070 seconds

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans & templates!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here