JSFiddle - React, Tailwind, and code Playground
by ryan_s
HTML
<form name="myform" method="post">
<input type="submit" name="operation" onclick="document.pressed=this.value" value="Save" />
<input type="submit" name="operation" onclick="document.pressed=this.value" value="Print" />
</form>
JavaScript
$(function(){
$('form[name="myform"] input[type="submit"]').click(function(event){
var $form = $('form[name="myform"]');
if($(this).val()=='Print'){
alert('print was pressed') ;
$form.attr('action','jbupdate.php');
}
else{
alert('save was pressed') ;
$form.attr('action','ppage.php');
}
});
$('form[name="myform"]').submit(function(event){
alert("form action : " + $(this).attr('action'));
event.preventDefault();
});
});