Problem of inserting multiple rows togather

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem of inserting multiple rows togather

rumana16
I've designed a table containing a static row and adding some multiple rows with add more button using js.there are many dynamic fields depending on other fields. the problem is i can't save all it togather.plz asny one can help me??

Jsp:

<form action="savecc" method="post">

   
        <input type="hidden" id="rowcountc" name="rowcountc"  value="1"/>                                                                     
<select size="1" name="ccname" id="ccid_1"
                             onchange="fetchItem(1,this.options[this.selectedIndex].value)"
                             style="font-size: 14px;width: 90px;">
            <option value="">Please Select</option>
            <s:iterator value="strList" >
                <option value="<s:property value="ccid" />"><s:property value="ccname"/></option>
            </s:iterator>
        </select>
       
            <div id="cctypecol_1" align="left" style="width: 90px; ">

            </div>
       
<input size="10" type="text" name="comments" id="comments_1">            <a href="#" style='color:red;font-weight: bold;font-size: 12px' onclick='javascript:removerow(this);'>
                Delete
       
            <input type="submit" value="Save"   />
       
            <a href="#" onclick="javascript:addRow(this);setTimeout(scrolltoBottom, 10);">Add More
       

</form>





Js: function addRow(element) {

    var r = element.parentNode.parentNode;
    var table2 = r.parentNode;
    var lastRow = table2.rows.length - 2;
    var rowid = parseInt(document.getElementById("rowcountc").value) || 1;

    var newRow = table2.insertRow(lastRow);
    newRow.id = rowid + 1;
    document.getElementById("rowcountc").value = rowid + 1;


    var newCell = newRow.insertCell(0);
    newCell.align = "left";
    el = document.createElement("select");
    el.id = "ccid_" + (rowid + 1);
    el.name = "ccname";


    try {
        el.addEventListener('change', function () {
            fetchItem(rowid + 1, this.options[this.selectedIndex].value)
        }, false)
    }
    catch (e) {
        el.attachEvent('onchange', function () {
            fetchItem(rowid + 1, this.options[this.selectedIndex].value)
        }, false)
    }


    newCell.appendChild(el);

    newCell = newRow.insertCell(1);
    newCell.align = "center";
    a = "<div id='cctypecol_" + (rowid + 1) + "' align='left' style='width: 85px;'>        </div>";
    newCell.innerHTML = a;


    newCell = newRow.insertCell(2);
    newCell.align = "center";
    a = "<input type='text' id='comments_" + (rowid + 1) + "' align='center' size='10'/>";
    newCell.innerHTML = a;

    newCell = newRow.insertCell(3);
    newCell.align = "left";
    a = "<a href=\"#\" onclick=\"return removerow(this)\" style='color:red;font-weight: bold;font-size: 12px'> Delete ";
    newCell.innerHTML = a;


    loadCC(rowid + 1);


    return false;
}


function loadCC(rowcount) {
    var k = 1;
    var ind = document.getElementById("ccid_" + rowcount);
    if (ind == null) return;


    ind.options.length = 0;
    ind.options[0] = new Option("Please Select", "");

    <s:iterator  value="strList">
    ind.options[k] = new Option("<s:property value="ccname"/>", <s:property value="ccid" />);
    k = k + 1;
    </s:iterator>


}




how can i save this according to arraylist on next action??