Populate 2nd dropdown based on 1st dropdown selection using jQuery, ajax, struts2 -


edit Is there any other way that I fill the second drop down as per 1 drop down selection? Jquery Ajax Post any link to any person.


I have updated the second dropdown based on the first dropdown selection. I'm using jQuery and Struts2 I want to update the second dropdown using jQuery's AJAX. Someone can help me code I tried with the method below but in some way I was unable to cross the action class parameters. Thank you in advance.

Edit: As I said, whatever code I am updating with.

Select the Case is the first dropdown, Choose the word is another, how to compute action. selCaseDropDown Hidden variables I want to get the selected value of the first dropdown in the action class, where I have the gator and setter methods for this variable. I got stuck in the first class of selected value in the action class. Was there. I have not done anything further to this point.

  $ ("# caseSelect"). Change (function () {$ ("# result"). Html ('retrieving ...'); var selCase = $ ("# caseSelect"). Val (); $ .ajax ({type: "post" Url: "/ dwdst / casetermcodes", data: {selCaseDropDown: selCase}, contentType: "Application / Jason; Charset = utf-8", Data type: "json", success: function (msg) {$ ("# term Select "). (0). Options.length = 0; $ (" Choose the word "). 0). Option [0] = New option (" Term codes "," -1 "); $ .eich (Msg.d), function (index, item) {$ ("#selection"). (0) Get the options [$ ("#diriod select") (0) .options.length] = new the option (Item.value, item.key);})}}, error: function () {warning ("failed to load code"); $ ("# Results") Hide ();}}};});   

Action class:

  Execute public string () {logger.info ("Selected values>" + selCaseDropDown); Return success; } Public string getSelCaseDropDown () {return selCaseDropDown; } Public Zero SetsecelsseedDrop Dropdown (string sellsdropdown) {this.selCaseDropDown = selCaseDropDown; }    

I have solved it by creating another small JSP which is only drop down (Second drop down) as HTML code and this will be a small page in my action result.

When the first page selects the call action below using the call code and overrides the drop down, then it is shown in JP first, only JSP

getSecondSelect is the verb which I am calling, which results in that little jsp.

tercodeResult div tag that is replaced with a new drop down.

selId is the selected value from the first drop down.

  $ .ajax ({type: GET}, url: "getSecondSelect", data: "selId =" + selCase, data type: "text / html; charset = utf-8", Success: function (msg) {$ ("# tercodeResult"). Html);}});    

Comments