Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
How to use <form:input in dynamically added rows in Javascript Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use <form:input in dynamically added rows in Javascript

    Hi All,

    I have to dynamically add a Row in my JSP.
    For this I have written a Javascript addNewRow function.
    This JS function is working fine,if I give <input type='text'..../>

    But I have to use the "<td><form:input path="fileName" size="10"/></td>" to be inserted.

    I want to bind these text boxes using spring with MS-SQL databse.
    I am not getting how to bind these text boxes?

    Mainly, please tell me how to use "<form:input path="fileName" size="10"/>"
    in JavaScript.

    Here is the JSP code snippet

    <script>
    //This function dynamically adds a new row.

    function addNewRow(tableRef){

    var count = "1";
    var count_row = 1;

    var myTable = document.getElementById(tableRef);

    var tBody = myTable.getElementsByTagName('tbody')[0];
    var newTR = document.createElement('tr');

    //create table cell 1
    var newTD1 = document.createElement('td');
    var strHtml1 = "<INPUT TYPE='text' NAME='fileName"+count_row+"' SIZE='10'>";
    newTD1.innerHTML = strHtml1.replace(/!count!/g,count);

    // append data to row
    newTR.appendChild (newTD1);


    // add to count variable
    count_row=count_row+1;
    count = parseInt(count) + 1;

    // append row to table
    tBody.appendChild(newTR);

    }

    </script>

    <!-- HTML Table-->
    <table id="tableRef">
    <tr>
    <td>File Name</td>
    </tr>
    <tbody>

    <!--
    When the user clicks on the "Add Row" Link, new row to be added here.
    Now it is working fine as I have given "<INPUT TYPE='text'...(see var strHtml1).
    I want to bind these text boxes using spring with MS-SQL databse.
    I am not getting how to bind these text boxes?

    Mainly, please tell me how to use
    "<form:input path="fileName" size="10"/>"
    in JavaScript.

    -->

    </tbody>

    <tr>
    <td colspan="1"><a href="javascript:addNewRow('tableRef')">Add Row</a></td>
    </tr>
    </table>


    Thanks in advance.
    Debasis
Working...
X