Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > get all value of all row of a dynamic html table

Reply
Thread Tools

get all value of all row of a dynamic html table

 
 
SAN CAZIANO
Guest
Posts: n/a
 
      12-14-2004
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>


 
Reply With Quote
 
 
 
 
RobB
Guest
Posts: n/a
 
      12-14-2004
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)">

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
row bottom border in inner table not matching up with row border in outer table phl HTML 1 06-08-2006 03:43 PM
Get the table row index from table DOM2 sudhaoncyberworld@gmail.com Javascript 3 12-05-2005 02:31 PM
How to Get Row Value of a Table from client side ... RC ASP .Net 1 06-02-2005 10:29 AM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Get 2nd cell value from table row? harry Javascript 2 07-22-2004 01:34 PM



Advertisments