JQuery in AA fails to update text field

1 week 6 days ago #338040 by krileon
Replied by krileon on topic JQuery in AA fails to update text field
Do you need the count actually stored in the database or do you just need it for display somewhere?

If it doesn't need to be sored there's ways of getting the count without having to use JavaScript here (mainly using CB Code Field and some PHP) and since it's not being displayed to them there isn't much point updating it with JavaScript. If it does need to be stored that can be done using CB Auto Actions and a Field action to more securely store it.

Where you're intending to display the count would also be useful since the custom display parameters in CB Field Groups allows you to output the row count already.


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 to join the conversation.

1 week 5 days ago #338052 by galanopd
Replied by galanopd on topic JQuery in AA fails to update text field

Do you need the count actually stored in the database or do you just need it for display somewhere?

I simply require it to be displayed without the need for storage.

If it doesn't need to be sored there's ways of getting the count without having to use JavaScript here (mainly using CB Code Field and some PHP) and since it's not being displayed to them there isn't much point updating it with JavaScript.

If I choose to do so, will I still be able to retain the CB Code field within the hidden tab and display it on the profile view somehow?

Where you're intending to display the count would also be useful since the custom display parameters in CB Field Groups allows you to output the row count already.

Not sure if this solution applies here, as I only require the count to be displayed in one section of the profile, while I need the rows of the CB Field Group to be displayed in another. So what I need is to pass the count to a text field (or a code field to get it) in order to display it where I need, while keeping the Field Group Rows visible elsewhere.

Please Log in to join the conversation.

1 week 5 days ago #338053 by krileon
Replied by krileon on topic JQuery in AA fails to update text field
Ok, if you don't need it for storage then you can do this entirely with PHP in a code field. You'd just decode the JSON data and count the rows. Example as follows.
$fieldGroup	=	$user->getRaw( 'FIELD_NAME_HERE', '' );

if ( ! $fieldGroup ) {
	return 0;
}

return count( json_decode( $fieldGroup, true ) );

Replace FIELD_NAME_HERE with the name of your field group field. Yes, you can hide this from profile edit entirely as it has no relevance there. If you need more control like counting a specific field inside of each row having a value you can loop the decoded JSON data and establish a count from it.


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.
The following user(s) said Thank You: galanopd

Please Log in to join the conversation.

1 week 3 days ago - 1 week 3 days ago #338082 by galanopd
Replied by galanopd on topic JQuery in AA fails to update text field
I appreciate it, it worked fine.

Thanks

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.171 seconds

Facebook Twitter LinkedIn