I am developing an application using servlets and Jsp. I have 2 drop down menu's. in first drop down menu i am retrieving Countries names from MySql Database. based on selection of country in second drop down states will come in second. I have done it by using Ajax. but my project manager told to do not use ajax. Just use simple java/ javascript.
How can i achieve this...
example:
country:
states:
how can i achieve it in jsp by using servlets/ java/ javascript. but not using Ajax...
Thanks & Regards,
Mike....
I don't know the reason sir. but I have to do it by using java script but not with Ajax . The 2 drop down menu must be in a single page like
Country: States:
submit
what i need is when i select country name from that list the states will automatically populate in second drop down menu which came from MySql database . i.e when i select india it should populate like bangaloor,chennai....etc...
Again, without Ajax you'll either need to:
Neither approach is very good when Ajax handles this so well.
I'm beginning to think your manage is rather clueless.
mike mimmis wrote:Thanks for reply . I already done the above code...
what i need is when i select country name from that list the states will automatically populate in second drop down menu which came from MySql database . i.e when i select india it should populate like bangaloor,chennai....etc...
You will have to use InnerHTML,or Ajax for that,if you want to do that without refreshing the page,I will prefer Ajax.If a page-refresh is not an issue,then you can call a javascript onchange function,that will submit the page.Based upon what you have selected in the previous drop down menu ,you can pass the parameter to another query,which will populate the next drop down menu.
rajarshi roy wrote:
mike mimmis wrote:Thanks for reply . I already done the above code...
If a page-refresh is not an issue,then you can call a javascript onchange function,that will submit the page.Based upon what you have selected in the previous drop down menu ,you can pass the parameter to another query,which will populate the next drop down menu.
ya i can use onchange() function how to pass this variable within single page i need that drop down menu. i.e
is there any way to convert javascript variable to java variable.. if any please provide me details....
Thanks & Regards,
Mike....
How about loading all the values when the page loads? I am thinking about loading up the page with [Country] values and also the values for the second drop-down. Then based on the value selected for the first drop-down (Country) you could change the options available in the second drop-down using Javascript. This would to change the options in the second drop-down without having to reload the page.
But as Bear already said, it is all unnecessary or rather pointless when Ajax can handle it amazingly well.
I feel for you because it looks like you've been assigned a Functional background lead, technical person wouldn't have such an opinion. :-(
SCJP 6, next stop - OCPJWCD!
I have done it upto two level with use of jsp,servlet and javascript (Not ajax),
like,
when you will select country, then its corresponding state will come, and when you will choose state then district name will come, but it become very complex, because of when page will reload ,previous value (country, state)also should be maintained,
krunal prajapati wrote:Hello all friends,
I have done it upto two level with use of jsp,servlet and javascript (Not ajax),
like,
when you will select country, then its corresponding state will come, and when you will choose state then district name will come, but it become very complex, because of when page will reload ,previous value (country, state)also should be maintained,
can you attatch code. It is more helpful for me....
Thanks and Regards,
Mike...
