Forums Register Login

Resfresh page and getting values when option is selected

+Pie Number of slices to send: Send
I wants to know that is it possible that, when i select the option from drop-down menu on jsp page ,it sends it on servlet and return back to same page with results as per option was selected.

Like, if I am selecting country name from drop-down menu at a time page is refreshed and the value below that country options which is ,options for cities are available with indian cities!!
I have tried to find but, in each code javascript is their...Is it possible without javascript?
+Pie Number of slices to send: Send
Doing this with JavaScript is the correct and modern way. Back before Ajax, you had to submit and refresh the whole page. You can still do that, but it will make your application looks like it was written 10 years ago.

Sort of like building a car today using a crank in the front to turn the motor.

Do have a valid reason to avoid JavaScript?
+Pie Number of slices to send: Send
Most modern sites use Javascript to provide a dynamic interface, almost every browser supports it. Personally I would use the onChange event on the dropdown box and use an Ajax approach to request and display the results. I hate sites that refresh or reload the whole page when you select something; it looks so outdated and clunky. You can write your own ajax code or use some 3rd party solutions.
+Pie Number of slices to send: Send
Ok..then can you give some advise on how to do this task?
and also that ,can javascript interact with FormBeans to get values from FromBean?
(I don't know javascript, so sorry If you found this questions stupid)
+Pie Number of slices to send: Send
What's a FormBean? It's not part of Servlets or JSP.

In any case, no: JavaScript, which executes on the client after the HTML is generated and delivered as the response, cannot directly interact with Java code running on the server to create that response.

There are likely hundreds to thousands of examples of doing this on the Web. Please search.

If you want to use jQuery for your Ajax and JavaScript needs (you should use a library, Ajax has too many cross-browser nuances to do it yourself) you can grab the free sample source code for my jQuery book. The code for chapter 8 shows how to use Ajax and JSP to populate dropdowns dynamically
+Pie Number of slices to send: Send
Oh, and if you want to understand how JSP works and why it cannot interoperate with JavaScript, I suggest reading this article.
+Pie Number of slices to send: Send
you can do that very easilye using javascript like this..

run this code...

+Pie Number of slices to send: Send
Thanks to all of you .. I got it..Ajax is necessery for this kind of problems and its a modren day design approach.I will try to follow the same in my project also.
+Pie Number of slices to send: Send
can anyone says that how to do the same using struts? because, when i am doing




and define the same demo() function as per above code , it doesn't gives any thing....code remains same!!
I like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 8458 times.
Similar Threads
Populating dropdown menu based on another
Prepopulating a jsp
servlet+html
Drop down from DataBase problem
Html drop down menu and applet issues
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:08:13.