dependent Combo box in AJAX

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • galamansi
    New Member
    • Feb 2008
    • 1

    dependent Combo box in AJAX

    hi,i would like to know how to fill a combobox2 in struts2 using AJAX depending on a particular value in the combobox1.Only the combobox2 should get refreshed everytime.pleas e help at the earliest.Thank you.
  • Jacotheron
    New Member
    • Jan 2008
    • 44

    #2
    Originally posted by galamansi
    hi,i would like to know how to fill a combobox2 in struts2 using AJAX depending on a particular value in the combobox1.Only the combobox2 should get refreshed everytime.pleas e help at the earliest.Thank you.
    If I have a problem like this (where a lot of people get the same problem), I usualy go to http://javascript.internet.com. On this site I get the scripts that are allready programmed. They can even send you the scripts by e-mail etc. Here's a link to the pages I would suggest according to your query: http://javascript.internet.com/navig...-comboxes.html, http://javascript.internet.com/navig...pdown-box.html. The script needs to be retyped in order to work if a change has been made.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Originally posted by galamansi
      hi,i would like to know how to fill a combobox2 in struts2 using AJAX depending on a particular value in the combobox1.Only the combobox2 should get refreshed everytime.pleas e help at the earliest.Thank you.
      If you want to use Ajax for this, trigger your Ajax request function in the onchange event handler for the first combobox. The Ajax function should make a request to a server-side script which returns the options, either as an HTML snippet which you just set to combobox2 or as XML or JSON which you will need to parse.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by Jacotheron
        If I have a problem like this (where a lot of people get the same problem), I usualy go to http://javascript.internet.com. On this site I get the scripts that are allready programmed. They can even send you the scripts by e-mail etc. Here's a link to the pages I would suggest according to your query: http://javascript.internet.com/navig...-comboxes.html, http://javascript.internet.com/navig...pdown-box.html. The script needs to be retyped in order to work if a change has been made.
        Those links don't use Ajax. All the data is already stored within JavaScript arrays. That is an alternative way - it's not always necessary to use Ajax for every task.

        Just a note on using ready-made scripts. Some are not really up-to-scratch. Check the date and look for browser detection. Some are too old and not up to date.

        Comment

        Working...