I'm using a form to send info to a PHP page (using 'GET').
I'd like to have two buttons underneath the form: one to preview the generated page, and one to download the generated page.
I found this solution for the preview part:
<script type="text/javascript">
$("form").submit(function() {
$("form").attr('target', '_blank');
return true;
});
</script>
Which works great.
To make the generated page available for download, I was generally using a normal submit button:
<input type="submit"
name="submit"
id="submit"
onClick="myFunction()"
value="Download Bonus Page" >
and on the generated PHP page, at the very top I added
<?php
$filename = 'bonuspage.html';
header('Content-disposition: attachment; filename=' . $filename);
header('Content-type: text/html');
// ... the rest of your file
?>
I'm wondering how I can combine both functions, because when I click either button, it's always the preview that opens - I can't get the download to work...