Re: Two dependent select tags with data from DB (ajax?) - please help:)
You have to fill the dependent select options when generating the form and set the default based on what the user submits. HTH, - Dardo Sordi. On Feb 6, 2008 11:10 AM, Anna P <[EMAIL PROTECTED]> wrote: > > Thank you both for help! Finally, I decided to use tutorial from > devmoz.com . > It works, but I have one problem. I use dependent selects in > registration form. Fields 'city_id' (first select) and > 'district_id' (second select) must be selected by user - both of them > are validated in form. > The problem is - when I select city and district and then fail with > another field (for example I won't enter my e-mail address in form, > just to make form validate data) - first select shows me the city I > chose, but second select doesn't show me the district I chose and it > also doesn't show district which belong to the chosen city (it shows > me nothing). Why is that? How to fix this? > Thanks in advance - Anna:) > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Two dependent select tags with data from DB (ajax?) - please help:)
Thank you both for help! Finally, I decided to use tutorial from devmoz.com . It works, but I have one problem. I use dependent selects in registration form. Fields 'city_id' (first select) and 'district_id' (second select) must be selected by user - both of them are validated in form. The problem is - when I select city and district and then fail with another field (for example I won't enter my e-mail address in form, just to make form validate data) - first select shows me the city I chose, but second select doesn't show me the district I chose and it also doesn't show district which belong to the chosen city (it shows me nothing). Why is that? How to fix this? Thanks in advance - Anna:) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Two dependent select tags with data from DB (ajax?) - please help:)
What you're looking for is a little javascript. I would recommend creating an action in the districts controller to dump out some json based on the city, or even some html that you can just dump inside the select control. There are assorted articles / blogs around the place already on getting cake to do nice json. The object you'll be wanting in your onchange (for the cities select) is Ajax.request. Cake uses prototype for its own Ajax (eg in AjaxHelper stuff) so you might as well stick with that. Don't forget to download it and include it with $javascript->link. If all that's a bit much, check out the Ajax Helper's observe field, which will allow you to specify the dom id of the district select control as the update source, and just have your ajax action dump out all the option tags to be included in the select. The slight problem with this is that it's time based rather than event based so would be a somewhat heavy handed solution. Hope that gives you a few pointers. Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Two dependent select tags with data from DB (ajax?) - please help:)
The mythical http://www.devmoz.com/blog/2007/04/04/cakephp-update-a-select-box-using-ajax/ seems exactly what you need. On Feb 1, 2008 9:47 AM, Anna P <[EMAIL PROTECTED]> wrote: > > Hello! > I'm wondering if anyone has any simple script or knows good tutorial > about two dependent select tags. > I use and understand a little of JS, but AJAX is too much for me. > I just need this one functionality from AJAX - I have two tables: > cities (id,name) and districts(id,city_id,name) > > I want to create two select tags: > > > > ['name']?> > > > > > ..options with districts dependent from the chosen city... > > > Anyone please help... > Can it be done like this... $cities are sorted by name, and when I > enter on the registration page (this is where I need these two select > tags), first select shows me first city from the $cities array and > second select shows me districts of this city. > Thank you in advance! > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Two dependent select tags with data from DB (ajax?) - please help:)
Hello! I'm wondering if anyone has any simple script or knows good tutorial about two dependent select tags. I use and understand a little of JS, but AJAX is too much for me. I just need this one functionality from AJAX - I have two tables: cities (id,name) and districts(id,city_id,name) I want to create two select tags: ..options with districts dependent from the chosen city... Anyone please help... Can it be done like this... $cities are sorted by name, and when I enter on the registration page (this is where I need these two select tags), first select shows me first city from the $cities array and second select shows me districts of this city. Thank you in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---