开发者

Django/jquery: Address forms - dyamically adding state drop down list if country is United States?

开发者 https://www.devze.com 2023-01-02 06:25 出处:网络
I have a django html form for address information.There is standard street, city, state/province, postal code, country fields.The country field is a drop down list.How can I make the state/province fi

I have a django html form for address information. There is standard street, city, state/province, postal code, country fields. The country field is a drop down list. How can I make the state/province field a drop down list if the selected country is united states and a free form text box if the country is anything else?

I'd prefer not to have to do a round trip to the server so proba开发者_StackOverflow中文版bly through jquery?


Simplest way is add javascript code on page which will be catch "country" event, and then loads data in to your selectboxes.

Or you can write custom field and widget for your form(but anyway you need to add custom javascript on form page)

0

精彩评论

暂无评论...
验证码 换一张
取 消