Since PHPMaker 10, now we are able to add the ability of disabling Submit button on click event easily and quickly. This is very useful if you want to create a custom form which contains a submit button, and after user clicked the button, then it will be disabled so that will prevent double-click or double submission.
Of course, alternatively of the example above, you can insert the code via Server Event and Client Scripts. So, no need to customize the generated code, and no need to customize the template file. However, for simplicity, let's use the generated blank page to try the code. You will see how powerful and flexible it is!
- Before generating the script files, make sure you have already selected Generate a blank page item under the Generate tab in order to generate the blank page.
- Click on the Generate button, and make sure from Other files section in the Generate dialog window, at least you have selected blankpage.php item.
- Now click on the Generate button to generate the blank page.
- Rename the generated blankpage.php file, for example, becomes: testdisablesubmit.php.
Open testdisablesubmit.php file by using your favorite text editor, then find the following code:
<!-- Put your custom html here -->
Below that code, please insert the following code:
- Save the change of the file, and call that testdisablesubmit.php file just like you call the certain .php page via browser. For example, my web application root address is: http://localhost/test/, then go type this address via your browser: http://localhost/test/testdisablesubmit.php
- Now you should see in the page, there is a new Text Box control and a Submit button which has the label Please Click This Button. Just type any value in the textbox, and then click on the button, then watch the effect on the button. It should be automatically disabled right after you click the button.