How to create a submit button that will disable in previous page after the submit button in current page is submitted?

Hi, I have this main page where user enters date and goes to second page, The user enters the date and click submit, once I click submit,the form is submitted and in the previous page(which is the main page) the submit button is disabled.

How to create a submit button that will disable in previous page after the submit button in current page is submitted?

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
	<link rel="stylesheet" type="text/css" href="print.css" media="print" />
<title></title>
</head>

<body>
<header><h4>Customer Purchase Order</h4></header>
<form action="test3.php" method="post">
<table style="border-collapse:collapse;" width="500" height="206" border="1">
		Date:&nbsp;&nbsp;<input type="text" name="sdate" placeholder="yyyy-mm-dd">&nbsp;&nbsp;
		<input type="submit" name="save" value="Save" onclick="myFunction()"><br><br>

<script>
function myFunction() {
    document.getElementById("mySubmit").disabled = true;
}
</script>
</table>
</form>
</body>
</html>

Hi user9791 welcome to the forum

You forgot to post your PHP code, but I’m guessing it’s a problem you’re having with either SESSION or COOKIE functions?

But I don’t have any php code.

Ah, OK. Because you posted in the PHP category (and added a redundant PHP tag) I assumed you were working with PHP code.

You also added a JavaScript tag. But the only JavaScript code you posted is to disable the submit input.

Depending on how critical it is that the submit be disabled (though I think I might go with simply not displaying the form or even the page) you could do this with

a JavaScript Cookie

or a PHP Session
http://php.net/manual/en/book.session.php

Thanks for the tips. By the way, what if I write a new code which also need to have the same button function but in php code, does it use the same way too?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.