Skip to Content Skip to Menu

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

auto action for cities

  • mfe13
  • mfe13
  • OFFLINE
  • Posts: 572
  • Thanks: 26
  • Karma: 5
11 years 3 months ago - 11 years 3 months ago #230047 by mfe13
auto action for cities was created by mfe13
Hello,

I added tables for postal codes linked with cities.
I created two fields:
[cb_villeauto] is a query that returns the name of the city according to [cb_codepostal], only it only works when you save the profile.

[cb_villeautodelim] which is a delimiter that displays the city and reported cp

Now I would like to create an action that updates [cb_ville] when [cb_codepostal] is changed
Javascript would be something like
Code:
$("cb_codepostal").on("change", function(){ $("cb_ville").text( get_ville(this) ); });
where get_ville() is a function ajax request returning the city

I do not know how to do now!

Can you help me?
thank you very much
Last edit: 11 years 3 months ago by mfe13.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48465
  • Thanks: 8280
  • Karma: 1443
11 years 3 months ago #230078 by krileon
Replied by krileon on topic auto action for cities
"on" will not work with CB. Our jQuery is rather out of date (to be fixed in CB 2.0 as there are backwards compatibility issues to be addressed). Your selectors are also not valid, you need to use a class, ID, element, etc.. Fields are set with their name as the ID for most basic fieldtypes so the below should work depending on what type of fields you're using.
Code:
$( '#cb_codepostal' ).live( 'change', function(){ $( '#cb_ville' ).val( get_ville( this ) ); });

Have no idea how your get_ville function works, but the above will at least change the value based off your postal code field being changed.


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.

  • mfe13
  • mfe13
  • OFFLINE
  • Posts: 572
  • Thanks: 26
  • Karma: 5
11 years 3 months ago #230106 by mfe13
Replied by mfe13 on topic auto action for cities
Hi

It was just an example. I would want add something wich auto-complete the field "town" after the field "Zipcode" is enter. All in ajax. I see the plugin "auto action". Can I do that with this or is there another maner, please ?

I have a table with town and zip, I can implemente all the js if necessary, but I don't know how to add the event on the field.

thanks

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48465
  • Thanks: 8280
  • Karma: 1443
11 years 3 months ago #230120 by krileon
Replied by krileon on topic auto action for cities
CB Auto Actions can at the least add the jQuery to the header of the page. You'd need to use the registration form display trigger and the profile edit display trigger. The Code action with Method set to jQuery will let you add jQuery and/or load jQuery plugins on the page. You may want to look into auto complete jQuery plugins as there's probably one available that you could just load in and use it to cut down on writing a bunch of jQuery to do 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.

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

Moderators: beatnantkrileon
Powered by Kunena Forum