onChange adding textfield__Not working..!!

Discussion in 'JavaScript' started by strgraphics, Apr 7, 2011.

  1. #1
    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 = '&#60;'
    }
    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...,
     
    strgraphics, Apr 7, 2011 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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):
     
    Cash Nebula, Apr 12, 2011 IP