Hello friends, Hear is my code.., i would like to add the text field on change select tag but its not working can you guys help me.!! <script type="text/javascript"> function addField(theTitle) { if(theTitle == '01') { document.getElementById('otherFieldContainer').innerHTML = '<s:textfield key="r-Npercentage" cssClass="textfieldb" name="Choose-Your-Own" />' }else if(theTitle == '02') { document.getElementById('otherFieldContainer').innerHTML = '<' } else { document.getElementById('otherFieldContainer').innerHTML =""; } } </script> <body> <s:select key="r-Nemptype" headerKey="-1" headerValue="-- Choose --" list="#{'01':'Hourly','02':'Salary'}" name="employeeRef(Choose your own)" onchange="addField(this.value);"></s:select> <div id="otherFieldContainer">Dynamic Fields</div> </body> Actually i am using struts2 tags...,
Be warned, I know nothing about struts2 According to the docs, there is no closing tag for select. Struts2 - Select Give this a go: <s:select key="r-Nemptype" headerKey="-1" headerValue="-- Choose --" list="#{'01':'Hourly','02':'Salary'}" name="employeeRef(Choose your own)" onchange="addField(this.value);" /> Code (markup):