dru dru - 29 days ago 7
jQuery Question

Set hidden variable value equal to entire HTML of table

I'm trying to POST the entire HTML for a dynamic table to another page which will parse the HTML as an XLS file. I can't seem to get the onClick jQuery correct though, as the generated .XLS file just has contains one cell that reads :

[object Object]
.

onsubmit='$j("#datatodisplay").val( $j("#table1") ).html()'


datatodisplay
is the name/id of the hidden variable,

table1
is the table name.

Answer

Move your html() inside the val() function:

onsubmit='$j("#datatodisplay").val( $j("#table1").html())'