This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Dependent Combo Box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Dependent Combo Box" Watch "Dependent Combo Box" New topic
Author

Dependent Combo Box

Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Dear Ranchers,

In my project, I need a depenedent combo box, I have got some inputs from some websites and i designed like this. The codes are given below





MySQL database details are here



The values are populating well and fine. In the code I have created arraylist in test2.jsp and is sending to country.jsp file. When it comes to country.jsp the values looks like this, when I select Kenya in the country.



Again when I, split it into two different arrays, i will get in first array
[001] and in second [Mombassa]

When I populate the value in the second combo box, I am getting the square brackets also.

Please help me to avoid the brackets.

Thanks in advance

Regards

Aravind Prasad
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Where are the square brackets coming from? Database?

Eric
Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
It is not coming from the database, When we check the out.println of the Array list it is coming with that.

Please try to check this program, I provided and check it out.

Thanks/Regards
Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Dear Ranchers,

I have removed the square brackets using substring and it is now working perfectly

Thank you for the help and support.

Regards

Aravind Prasad
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Terminology correction: there is no such thing as a "combo box" on the web. Please read this for more information.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sanjeev P Kulkarni
Greenhorn

Joined: Nov 08, 2009
Posts: 20

Thanks a lot for sharing this code. This code is truly a worth sharing here as I have searched a lot for this code. Can you please tell me how to remove those square brackets? As I am also trying to use your code, but couldn't figure out how to remove them. Please help me thanks.

Aravind Prasad wrote:Dear Ranchers,

I have removed the square brackets using substring and it is now working perfectly

Thank you for the help and support.

Regards

Aravind Prasad


Sanjeev
subhash kumar
Ranch Hand

Joined: Jul 14, 2010
Posts: 63
Sanjeev Pk wrote:Thanks a lot for sharing this code. This code is truly a worth sharing here as I have searched a lot for this code. Can you please tell me how to remove those square brackets? As I am also trying to use your code, but couldn't figure out how to remove them. Please help me thanks.

Aravind Prasad wrote:Dear Ranchers,

I have removed the square brackets using substring and it is now working perfectly

Thank you for the help and support.

Regards

Aravind Prasad


sanjeev have done something like


so add your list to response by removing the brackets by substring method

Subhash Kumar
Attitude is everything
Sanjeev P Kulkarni
Greenhorn

Joined: Nov 08, 2009
Posts: 20

subhash kumar wrote:
Sanjeev Pk wrote:Thanks a lot for sharing this code. This code is truly a worth sharing here as I have searched a lot for this code. Can you please tell me how to remove those square brackets? As I am also trying to use your code, but couldn't figure out how to remove them. Please help me thanks.

Aravind Prasad wrote:Dear Ranchers,

I have removed the square brackets using substring and it is now working perfectly

Thank you for the help and support.

Regards

Aravind Prasad


sanjeev have done something like


so add your list to response by removing the brackets by substring method


Thanks a million Sir. This code is one of the valuable and most widely used. Thank you once again for helping me...
Sanjeev P Kulkarni
Greenhorn

Joined: Nov 08, 2009
Posts: 20

Sanjeev P Kulkarni wrote:
subhash kumar wrote:
Sanjeev Pk wrote:Thanks a lot for sharing this code. This code is truly a worth sharing here as I have searched a lot for this code. Can you please tell me how to remove those square brackets? As I am also trying to use your code, but couldn't figure out how to remove them. Please help me thanks.

Aravind Prasad wrote:Dear Ranchers,

I have removed the square brackets using substring and it is now working perfectly

Thank you for the help and support.

Regards

Aravind Prasad


sanjeev have done something like


so add your list to response by removing the brackets by substring method


Thanks a million Sir. This code is one of the valuable and most widely used. Thank you once again for helping me...


Just a small doubt, How to get the value of a port selected in your country.jsp??? because I need to save both the combo box values into the database. I tried document.form.state.value also tried printing document.frmVal.stateId.options.add(optn); but nothing is working out.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dependent Combo Box
 
Similar Threads
Ajax in JSp
Regading getElementById
implementing jsp, jdbc and javascript together
Dynamic Combo Box in JSP using AJAX
Populating the ComboBox by selecting another