Hi, I have two dropdowns, one is populated, the other one will be populated the the user change the first one, just before the first dropdown I added a data attribute in a label : ========================================================== <label for="environment" id="envtypes" class="formLabel" data-envtypes="${rRuleTypes}"><bean:message key="label.environment" />*</label> <html:select title="Environment" styleId="envtype" property="envType" tabindex="1"> <logic:iterate id="icxm" name="icEnvironments"> <html:eek:ption value="${icxm}">${icxm}</html:eek:ption> </logic:iterate> </html:select> <br/> Code (markup): =================================== The second drop down looks like this : <select id="typesId"> <option>Select State</option> </select> Code (markup): ==================================== rRuleTypes string coming from the server side is a concatination of string1-string2,string3-string4,.... my rRuleTypes is : PROD-PROD_TREST_RENAME_RULE,PROD-XPATH,QA-JAVA,QA-PHP,QA-QA_MASON_RENAME_RULE,QA-XPATH,TEST-BAT,TEST-PHP,TEST-STEVERR_UPDATE,TEST-XML,TEST-XPATH, ===================================================== I started to write the jquery : $(document).ready(function() { $("#dropdownCountry").change(function (e) { var envtypes = $("#envtypes").data('envtypes'); var env = $("#envtype").val(); HERE I NEED TO PARSE envtypes BY , whatever found parse it by -, if the first part is equal to variable env append it to a variable called appenddata. $("#typesId").append(appenddata); }); }); Code (markup):
Can you post a link to this in jsfiddle or something similar? It's much easier for me to help you when I can actually see the code working.