Country/State Dropdown in CakePHP -


How do I deal with the combo box in the ideas with the form assistant? For example:

Select the country box (Selecting the country will filter the selected country states) Select the States box

This will be with the help of JavaScript / Junkies etc. I came to an example with the main AJAX assistant of cake, but it would be great if someone could help in javascript example.

Thanks

thoughts / edit.ctp

  & lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ('# country'). Change (function () {$ ('# state'). Load ('/ controller / getstates /' + $ (this) .val ( ));});}); & Lt; / Script & gt; & Lt; Select ID = "Country" name = "country" & gt; & Lt; Option value = "1" & gt; Greece & lt; / Options & gt; & Lt; / Select & gt; & Lt; Span id = "state" & gt; & Lt; Select name = "state" & gt; & Lt; Option value = "" & gt; & Lt; / Options & gt; & Lt; / Select & gt; & Lt; / Span & gt;  

and the controller.php

  function getStates (int countryID) {$ this- & gt; Set ('selectbox', $ this-> state - & gt; address ('list', array ('conditions' = & gt;' state.ountry_id = '. $ Country id,' field; = & gt; ; Array ('description'));}  

and thoughts / getstates.ctp

  & lt; select name = "state" & gt; ; & Lt; Option value = "" & gt; & lt; / option & gt; & lt; php foreach $ option as option $) echo '& lt; Option value = "'. $ Option [' id ']." & Gt; '. $ Option ['description']. ' & Lt; / Options & gt; I hope I can not forget anything 


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -