I have a three-button form. First button "only Save document", second button "only generate PDF" and third button "Save document and Generate PDF".
only Save button - just submitting form - works fine
<form method="post">
<button type="submit" name="save">
<input>....
</form>
only Generate PDF button - change form action and target with simple jquery and send it to PDF generator - also works fine
<form method="post">
<button type="submit" name="generate" id="generate">
<input>....
</form>
<script>
$('#generate').click(function(){
$('form').get(0).setAttribute('action', './library/pdf/generator.php');
$('form').get(0).setAttribute('target', 'blank');
});
</script>
Save document and Generate PDF button - here i need merge both in one on one click... submit + save data and open PHP generator in new tab(window) .. both with same POST data ... Any ideas? I'm stuck here
EDIT: Tried this callback without luck.. it open only pdf generator (im begginer in jquery, so maybe its nonsence)
$(function() {
$('#saveandgenerate').click(function(){
$('form').get(0).setAttribute('action', './library/pdf/generator.php');
$('form').get(0).setAttribute('target', 'blank');
$('form').get(0).submit(function(){
$('form').get(0).setAttribute('action', '');
$('form').get(0).setAttribute('target', '');
$('form').get(0).submit();
});
});
});