Is it possible to pass the value of an HTML table through post or not? I'm making a PDF report, and want to get only in my HTML table.
Asked
Active
Viewed 46 times
0
-
I don't see why not. An HTML table is simply a string of characters, which POST can easily handle. You would just have to ensure it is processed properly on the receiving end. – Russ J Mar 13 '19 at 02:04
-
is it
this is right?
– Alfredo Ramirez Mar 13 '19 at 02:30 -
No, you cannot use the 'name' attribute in an HTML table. Try id or class instead. https://stackoverflow.com/questions/13677536/can-we-give-name-to-html-table – Russ J Mar 13 '19 at 02:31
-
– Russ J Mar 13 '19 at 02:32
-
Please share sample code, so that it will be helpful to understand. – Rashedul Islam Sagor Mar 13 '19 at 02:56
2 Answers
0
sure, just create a valid form and send the content ..
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<form id="f">
<input type="hidden" name="mytable" />
<button>Submit</button>
</form>
<table id="t">
<tr>
<td>ra ra</td>
</tr>
</table>
</body>
<script>
$(document).ready( function() {
$('#f').on( 'submit', function( e) {
let t = $('#t');
$('input[name="mytable"]', this).val( t[0].outerHTML)
console.log( $(this).serializeArray());
return false;
});
});
</script>
</html>

David Bray
- 566
- 1
- 3
- 15