Reputation: 235
I am displaying some records table where each row contains two buttons like
"Accept" and "Reject"
If I click on "Accept" then the form should be submitted and the button should Replace with "Cancel" button and page should reload with fresh content in the table.
And If I click on "Reject" button then "Accept" button should hide And page should reload with fresh content.
I have tried something but did not work.
$(document).ready(function(){
$("#upComing").submit(function(){
alert("Submitted");
});
$("#btnAccept").click(function(){
$("form[value='Accept${upComLeave.employee_id}']").submit();
location.replace("#btnCancel");
});
});
please help me.
Upvotes: 1
Views: 89
Reputation: 4886
You can have three buttons, Accept, Cancel (hidden at first) and Reject and show and hide them to achieve what you describe:
$('#btAccept').click(function(){
$(this).hide();
$('#btCancel').show();
//submit form
});
$('#btCancel').click(function(){
//cancel ajax request
return false; //prevent form from submitting
});
$('#btReject').click(function(){
$('#btAccept').hide();
//refresh content
return false; //prevent form from submitting
});
Here's a fiddle that shows it working.
Upvotes: 1