开发者

Design/Implementation...most likely with AJAX

I have a problem that is common, but I am not quite sure exactly how do go about solving it.

My situation is 开发者_运维问答I have a form that will have a drop down of States. I also have a drop down that should have military installations(bases), but the bases that are populated are dependent on the value of the state dropdown.

In my database I will have a table BASES such as the following most likely.

BASES Table
            int base_id
            varchar state
            varchar base_name
            varcar  city

When a customer selects a state, I need to query all the bases in that state. and return them and populate the bases drop down. I am well aware that I can do this easily by just posting the data to the server as form data, but I would rather find a simpler solution and I know ajax is used to solve problems like this one.

I am entry level, and ajax is a new topic for me so any help I can get would be appreciated.

I am using Java/JSP/Servlets and am using MySQL.


If you think that AJAX is the solution, and you're using Java, then check out DWR. It allows you to trivially expose Java objects in Javascript. You can create a server-side object to derive your list of data for pull-down menus and easily expose this in Javascript.


This can all be solved with javascript alone if you hardcoded the state/base relationship into an array(s) in the javascript file.

Here is an example I found on the internet.

http://www.javascriptkit.com/javatutors/selectcontent2.shtml

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜