After rereading this, if tables are same size and same config; the
following clones the existing table and strips out all inputs inserting
the values as text in new table
$("#originalTable").clone(function () {
$("#originalTable").clone().appendTo("body").attr("id","newTable");
$("#newTable td").each(function () {
var newText = $(this).find("input").val(); // get value
from input
$(this).html(newText); //replace input with new html which
is just text
});
Working example http://jsbin.com/uroca
Charlie wrote:
this isn't exactly
clear but sounds like you are taking input values
and want them as straight text in a <td> of the new table?
how you go about this will depend a lot on the size and structure you
have for markup as well as how much of original goes into new table.
Could be as simple as clone() of the original table, and a $each for
the td's to strip the inputs and change them to text then remove rows
or columns. Very hard to guess what "part of the output" means. There
are numerous methods, clone original ,indexing, working with classes or
ID's to append to new table.
Posting a sample page of old and new with a little more detail on your
requirements would make solutions a lot easier to identify. If can't
post on server jsbin.com is excellent for this
david wrote:
Hi all,
I have a table of input elements which i create through a _javascript_
widget.
When i press submit i want to make an action and a part of the output
should be the same unchanged tables with the values in it.
I don't know how to accomplish it.
At first i used the html() function, but it does not pass the table
with the html values inserted as i would like.
Has anyone an idea how to make it ?
Thanks,
David
|