Jump to content
ravi_k

submit and hide

Recommended Posts

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Hi

I have changed my code as below.

<form action="/action_page.php" method="post">
Testing: &emsp;&nbsp;&nbsp;<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

Share this post


Link to post
Share on other sites

Give each button a name, then check on the server whether the name exists in the $_POST array and what value it has.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...