Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to populate dependant <html:select>

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
In the renaissance, how big were the dinosaurs? Did you have tiny ads?
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic