Reputation: 79
I have a form with 2 buttons: Approve and Reject.
<input type="button" name="Approve" value="Approve" onClick="location.href='approve.php?user=<?php echo $row['icnum'];?>&states=1'">
<input type="button" name="Reject" value="Reject" onClick="location.href='approve.php?user=<?php echo $row ['icnum'];?>&states=2'">
I want to disable the "Reject" button once the "Approve" button is clicked. So, the user cannot reject the form again after it has been approved.
I have tried several attempts, like:
<input type="button" value="Send" onclick="javascript=this.disabled = true; form.submit();">
But this code does not work for me. Even if it's actually working, the button is just disabling itself, not the other button.
I'm using Chrome. Any idea on how to solve this?
EDIT: This is my process form in php.
<?php session_start();
include('../include/dbconnect.php');
$user = $_GET['user'];
$states = $_GET['states'];
if($user){
$approve = "UPDATE student SET status='$states' WHERE icnum='$user'";
$result = mysql_query($approve) or die(mysql_error());
if ($result) {
?>
<script type="text/javascript">
window.location = "index.php"
</script>
<?php }
}
?>
What can I edit into these codes if the action is ran in the server-side?
Upvotes: 1
Views: 825
Reputation: 53
Try below
<asp:Button ID="cmdSubmit" runat="server" Text="Submit" onclick="btnSumbit_Click" onclick="btnSumbit_Click" OnClientClick="this.style.display = 'none';"/>
Upvotes: 0
Reputation: 63587
In jQuery:
$('input[name=Approve]').click(function () {
$('input[name=Reject]').prop({disabled: true});
});
Upvotes: 0
Reputation: 3281
Remove the javascript= from OnClick. You only need javascript: (colon not =) for anchors' hrefs
<input type="button" value="Send" onclick="this.disabled=true; formName.submit();">
Upvotes: 1