By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,272 Members | 1,437 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,272 IT Pros & Developers. It's quick & easy.

get all value of all row of a dynamic html table

P: n/a
I have create a dynamic html table by adding some rows where I have to put
some value in an input field and now how can I get all value of all row ???

I try this but it doesn' work
button onclik=Alert("EditFieldValue2.value");

Please reply me as soon as possible.

<script>
function addRowToTable()
{
var FieldArray=new Array("ID","CodiceArticolo","Ltd");

var tbl = document.getElementById('SearchTable');
var lastRow = tbl.rows.length;

// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);

// numero progressivo
var cellFirst = row.insertCell(0);
var textNode = document.createTextNode(iteration);

cellFirst.appendChild(textNode);

// edit per il valore da ricercare sul campo
var cellOne = row.insertCell(1);

var el = document.createElement("input");
el.setAttribute('type', 'text');
el.setAttribute('size', '40');
el.setAttribute('name', 'EditFieldValue' + iteration);
cellOne.appendChild(el);
}

function removeRowFromTable()
{
var tbl = document.getElementById('SearchTable');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}

function openInNewWindow(frm)
{
// open a blank window
var aWindow = window.open("", "TableAddRowNewWindow",

'scrollbars=yes,menubar=yes,resizable=yes,toolbar= no,width=400,height=400');

// set the target to the blank window
frm.target = "TableAddRowNewWindow";

// submit
frm.submit();
}
</script>

<form action="tableaddrow_nw.html" method="get">

<input type="button" value="Add" onclick="addRowToTable();" />
<input type="button" value="Remove" onclick="removeRowFromTable();" />
<input type="button" value="Submit" onclick="openInNewWindow(this.form);" />
<table border="1" id="SearchTable">
<tr>
<th colspan="5">Sample table</th>
</tr>
<tr>
<td>1</td>
<td><input type="text" name="EditFieldValue1" size="40" /></td>
</tr>
</table>

</form>
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
SAN CAZIANO wrote:
I have create a dynamic html table by adding some rows where I have to put some value in an input field and now how can I get all value of all row ???
I try this but it doesn' work
button onclik=Alert("EditFieldValue2.value");

Please reply me as soon as possible.

<script>
function addRowToTable()
{
var FieldArray=new Array("ID","CodiceArticolo","Ltd");

var tbl = document.getElementById('SearchTable');
var lastRow = tbl.rows.length;

// if there's no header row in the table, then iteration = lastRow + 1 var iteration = lastRow;
var row = tbl.insertRow(lastRow);

// numero progressivo
var cellFirst = row.insertCell(0);
var textNode = document.createTextNode(iteration);

cellFirst.appendChild(textNode);

// edit per il valore da ricercare sul campo
var cellOne = row.insertCell(1);

var el = document.createElement("input");
el.setAttribute('type', 'text');
el.setAttribute('size', '40');
el.setAttribute('name', 'EditFieldValue' + iteration);
cellOne.appendChild(el);
}

function removeRowFromTable()
{
var tbl = document.getElementById('SearchTable');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}

function openInNewWindow(frm)
{
// open a blank window
var aWindow = window.open("", "TableAddRowNewWindow",

'scrollbars=yes,menubar=yes,resizable=yes,toolbar= no,width=400,height=400');
// set the target to the blank window
frm.target = "TableAddRowNewWindow";

// submit
frm.submit();
}
</script>

<form action="tableaddrow_nw.html" method="get">

<input type="button" value="Add" onclick="addRowToTable();" />
<input type="button" value="Remove" onclick="removeRowFromTable();" /> <input type="button" value="Submit" onclick="openInNewWindow(this.form);" /> <table border="1" id="SearchTable">
<tr>
<th colspan="5">Sample table</th>
</tr>
<tr>
<td>1</td>
<td><input type="text" name="EditFieldValue1" size="40" /></td>
</tr>
</table>

</form>
This is a mess:
button onclik=Alert("EditFieldValue2.value");


Most people would know what you're trying to do, but sloppiness does
not sit well with programming. In any event, you also didn't mention
browser/error message etc. so I'll assume Internet Explorer - which
doesn't add references to form elements generated with .createElement()
to either the document object or the form's .elements[] collection.
Might want to do it yourself:

<input type="button" value="Add" onclick="addRowToTable(this.form);" />
<input type="button" value="Remove"
onclick="removeRowFromTable(this.form);" />
.................
function addRowToTable(frm)
{
var FieldArray=new Array("ID","CodiceArticolo","Ltd");
var tbl = document.getElementById('SearchTable');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// numero progressivo
var cellFirst = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellFirst.appendChild(textNode);
// edit per il valore da ricercare sul campo
var cellOne = row.insertCell(1);
var el = document.createElement("input");
el.setAttribute('type', 'text');
el.setAttribute('size', '40');
el.setAttribute('name', 'EditFieldValue' + iteration);
frm[el.name] = frm.elements[el.name] = el;
cellOne.appendChild(el);
}

function removeRowFromTable(frm)
{
var tbl = document.getElementById('SearchTable');
var lastRow = tbl.rows.length;
if (lastRow > 2)
{
tbl.deleteRow(lastRow - 1);
frm['EditFieldValue' + --lastRow] = frm.elements['EditFieldValue' +
lastRow] = null;
}
}

btw it's <input type="button" value="show"
onclick="alert(EditFieldValue2.value)">

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.