views:

308

answers:

0

Hi, I am trying to make a dynamic form using Spring forms. Basically in my jsp page i have button to Add input text boxes, I can add as many as i want. Dynamically am adding these text boxes using javascript and spring:bind tag. And values also binding to bean object. And i can pass these values to next page also. As we know in spring web flow we can navigate back and forth and can print values in first page. But here when i am coming back the values are not showing in first page (i mean not getting values from bean).

As i found problem was when am using form tag means , I can able to get the values again back in first page.

So how can i add these form:input tag using js or ajax or any other method ?. While am trying ajax to add form:input tag its not rendering.

Here is code what i tried..


<script language="javascript"> 
 fields = 0;
 function addInput() {
               var table = document.getElementById('names');
               var row = table.insertRow(table.rows.length);
               var cell0 = row.insertCell(0);
               cell0.appendChild("<input type='text' name='name'/>");
 }


 <form:form commandName="student">
   <spring:bind path="name"/>
      <table id="names">
      </table>
   </spring:bind>
   <input type=button onclick="addInput()"/>
   <input type="submit"/>
 </form:form>