I have a PHP page which generates an HTML table. At the bottom of the page, you can click a 'submit' button and the data from the table is sent to a jquery script called Table2CSV (link here) which takes the data, and submits to another php script for CSV export.
Ultimately, all of the action takes place here:
<form action="getCSV.php" method ="post" >
<input type="hidden" name="csv_text" id="csv_text">
<input type="submit" value="Get CSV File"
onclick="getCSVData()"
</form>
<script type="text/javascript">
function getCSVData(){
var csv_value=$('#example2').table2CSV({delivery:'value'});
$("#csv_text").val(csv_value);
}
</script>
What I'd like to do is generate the csv script without ever having to output the html table to the screen (via a link click on another page).
I think I ultimately need to simply change the javascript function above to call getCSVdata on page load then run getcsv.php but not sure how to do that exactly as I'm not very familiar with JS.
Any suggestions?