ravi_k Posted October 27, 2018 Share Posted October 27, 2018 Hi I am trying to submit the form and also when start is pressed, it should be disabled and only stop to be avialable. I tried below code but submit form is not happening <form action="/action_page.php" method="post"> Testing: <input name="ip" id="ip" type="text" min="0" max="255"> <input type="submit" id="start" value="start" onclick="myFunction1()"> <input type="submit" id="stop" value="stop" onclick="myFunction2()"> </form> <script> function myFunction1() { document.getElementById("start").disabled = true; document.getElementById("stop").disabled = false; } function myFunction2() { document.getElementById("start").disabled = false; document.getElementById("stop").disabled = true; } </script> Thanks with Regards Ravi K Link to comment Share on other sites More sharing options...
Ingolme Posted October 27, 2018 Share Posted October 27, 2018 You're disabling the button right when it is clicked, so it won't make the form submit, but if you don't disable it then the form will submit, leaving the page and resetting the button states anyway. What is your end goal with this? Link to comment Share on other sites More sharing options...
dsonesuk Posted October 27, 2018 Share Posted October 27, 2018 Click 'start' submitted-> gone!...disable whaaaaaaoooooooo...... Click 'stop' submitted->gone! ...enable whaaaaaaoooooooo...... Once the form is submitted to another page, it wouldn't get a chance to Disable/Enable anything as it goes instantly to the URL set in the 'action' attribute. The form page is left on submission, and when return to, if you had! managed to Disable/Enable anything! They will be reset to there default state. Link to comment Share on other sites More sharing options...
ravi_k Posted October 30, 2018 Author Share Posted October 30, 2018 Hi I have changed my code as below. <form action="/action_page.php" method="post"> Testing:   <input name="ip" id="ip" type="text" min="0" max="255"> <input type="submit" value="Start"> <input type="submit" value="Stop"> </form> How can i differentiate which button is pressed on server side whether its start or stop. Please suggest Thanks with Regards Ravi K Link to comment Share on other sites More sharing options...
Ingolme Posted October 30, 2018 Share Posted October 30, 2018 Give each button a name, then check on the server whether the name exists in the $_POST array and what value it has. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now