• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How to populate dependant <html:select>  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I have two drop down boxes; one contains "State" and other contains "City".
I wish to populate Cities according to the value selected in State Drop down.
For this I would like to use Ajax to avoid page refresh. And for fetching values in City I am using Struts Action class to give call to server side code.
Does anyone know; How to do this?

Thanks in advance.
 
Ranch Hand
Posts: 2908
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sameer Sb wrote:Does anyone know; How to do this?[/size]


Do you have any knowledge of AJAX, if no, this link will give you start.
 
Sameer Sb
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sagar,

Thanks for reply.
I know ajax a little bit and know how to build URL and call struts action from a javascript.
I am getting data from my DAO classes format those in Struts Action class in format id,value;id,value;id,value.
Could also separate this in further step by using split and could get id and value in a for loop.
my question is then how to update the dependant <html:select> on the jsp?

 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thing first, this is not the question for Struts section. Ask AJAX question in HTML-Jsvascript section.

Sameer Sb wrote:
I am getting data from my DAO classes format those in Struts Action class in format id,value;id,value;id,value.


Called JSON

Sameer Sb wrote:my question is then how to update the dependant <html:select> on the jsp?


Once you get that JSON string on client side, evalualte/parse it using function eval() and "write" the HTML or TEXT to select element, something like this


(please look for the correct syntax)
 
We noticed he had no friends. So we gave him this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!