Chandrasekaran C

Chandrasekaran C

  • 1.7k
  • 132
  • 964

How to I get values of n numbers of table row input in asp?

Aug 31 2019 2:11 AM
Hi
I done the input field as custom if cusomer need we create n numbers, But How I get this N number value to store db 
 
//Asp.Net
//Web Page
<table id="epcgCon">
<tr>
<th>S.No</th>
<th>Description of Items</th>
<th>Quantity</th>
<th></th>
</tr>
<tr>
<td>//S.NO
</td>
<td>
//Description Item String value
</td>
<td>
//Qty in integer
</td>
<td>// Remove button
</td>
</tr>
</table>
<div>
<input type="button" onclick="AddRow('epcgCon')" value="ADD ROW" />
</div>
<div>
<input type="button" onclick="Submit()" value="Submit" />
</div>
//JavaScript Coding...
var count = "1";
function AddRow(in_tbl_name) {
var tbody = document.getElementById(in_tbl_name).getElementsByTagName("TBODY")[0];
// create row
var row = document.createElement("TR");
// create table cell 2
var td1 = document.createElement("TD")
var strHtml2 = ""+count;
td1.innerHTML = strHtml2.replace(/!count!/g, count);
// create table cell 3
var td2 = document.createElement("TD")
var strHtml3 = "<input type=\"text\" name=\"Descr\" />";
td2.innerHTML = strHtml3.replace(/!count!/g, count);
// create table cell 4
var td3 = document.createElement("TD")
var strHtml4 = "<input type=\"text\" name=\"Qty\" />";
td3.innerHTML = strHtml4.replace(/!count!/g, count);
// create table cell 5
var td4 = document.createElement("TD")
var strHtml5 = "<input type=\"button\" value=\"Remove\" onClick=\"delRow()\"/>";
td4.innerHTML = strHtml5.replace(/!count!/g, count);
// append data to row
row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);
count = parseInt(count) + 1;
// add to count variable
// append row to table
tbody.appendChild(row);
}
function delRow() {
var current = window.event.srcElement;
//here we will delete the line
while ((current = current.parentElement) && current.tagName != "TR");
current.parentElement.removeChild(current);
}//Delete Row END
Submit()
{
var desc=document.getElementByName('Descr');
var qty=document.getElementByName('Qty');
// I need help on this How to I get value from if n numbers and insert into DB
}

Answers (3)