Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount! Get 20% off now with code SPOOKY-2024!

Check Box (Multiple) fields

  • tiekubd
  • tiekubd
  • OFFLINE
  • Posts: 68
  • Thanks: 1
  • Karma: 0
7 years 11 months ago #287894 by tiekubd
Replied by tiekubd on topic Check Box (Multiple) fields
Hopefully if you give me a simple example of what you describe using the 3 values (val1_5, val2_5, val3_5) I can expand on it to perform other calculations.

This is the main feature of my site.

Thanks advance.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48454
  • Thanks: 8280
  • Karma: 1443
7 years 11 months ago #287916 by krileon
Replied by krileon on topic Check Box (Multiple) fields
I've already provided you a simple example here.

www.joomlapolis.com/forum/153-professional-member-support/235236-check-box-multiple-fields?limitstart=0#287883

The only change you need to make is splitting the values in the foreach loop to remove the unique part. I explained several ways you can do that here.

www.joomlapolis.com/forum/153-professional-member-support/235236-check-box-multiple-fields?limitstart=0#287890

Simple preg_replace will probably be fine. Example as follows.

Code:
$total = 0; foreach ( explode( '|*|', '[cb_myfield]' ) as $value ) { $total += (int) preg_replace( '/^val\d+_/', '', $value ); } return $total;

The above will remove val1_, val2_, etc.. leaving just the 5.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • tiekubd
  • tiekubd
  • OFFLINE
  • Posts: 68
  • Thanks: 1
  • Karma: 0
7 years 11 months ago #287924 by tiekubd
Replied by tiekubd on topic Check Box (Multiple) fields
I'll give this a try right away. Thanks

Please Log in or Create an account to join the conversation.

  • tiekubd
  • tiekubd
  • OFFLINE
  • Posts: 68
  • Thanks: 1
  • Karma: 0
7 years 11 months ago #287925 by tiekubd
Replied by tiekubd on topic Check Box (Multiple) fields
Looks like it's working!
Thanks !!!!!!!!!!!!

Where do you have documentation that explains the difference/uses of the different Code field types?

Code
Code Check Box (Multiple)
Code Drop Down (Multi-select)
Code Drop Down (Single Select)
Code Radio Buttons

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48454
  • Thanks: 8280
  • Karma: 1443
7 years 11 months ago #287932 by krileon
Replied by krileon on topic Check Box (Multiple) fields

Where do you have documentation that explains the difference/uses of the different Code field types?

There isn't any. A Code field simply outputs your code kinda like a Custom HTML field with PHP. A Code Check Box (Multiple) simply outputs a multicheckbox usage except the multicheckbox values come from PHP instead of just what's defined under the description parameter; the same basically applies for the select and radio code fieldtypes as well.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • tiekubd
  • tiekubd
  • OFFLINE
  • Posts: 68
  • Thanks: 1
  • Karma: 0
7 years 11 months ago #287942 by tiekubd
Replied by tiekubd on topic Check Box (Multiple) fields
Can I safely use the same variable name ($total) for more than one code field, or should it be unique?

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum