Karenina
Karenina

Reputation: 49

Enable submit button with javascript

First, i have a code that i need to know if the user has clicked on one submit button, then, i need one function to enable another submit button that is disabled by disabled="disabled".

Here's my noob function (Needs improves, does not work). :

<script>
    function EnableSend() {
    if(document.getElementById("Submit_Facebook").click(); {
    document.getElementById("submit").disabled = false; }
    }
 </script>

And now the code:

1 - Disabled Submit: (Will be enabled after user click on Submit_Facebook submit button).

<input id="submit" name="submit" type="submit" value="" disabled="disabled">

2 - Other submit that will make the disabled submit enabled.

<form method="post" class="button" action="<?=$PHP_SELF;?>"">
 <input id="Submit_Facebook" name="Submit_Facebook" type="submit" value=""onclick="EnableSend()">
</form>

3 - Php part

<?php
if (isset($_POST['Submit_Facebook'])) {
echo "<script>alert('You now can proceed to step two.');</script>";
echo '<script type="text/javascript"language="javascript">window.open("#");</script>'; 
exit;
}?>

Well, my english is not that good, but if you guys need any detail just contact me, thanks for your attention.

Upvotes: 3

Views: 9007

Answers (2)

Moe84
Moe84

Reputation: 11

You got to remove disabled attribute from input.

Something like this:

var EnableSend = function(){
  $( "#submit" ).removeAttr('disabled');
};

Upvotes: 1

tgogos
tgogos

Reputation: 25142

jsFiddle

<input id="submit" name="submit" type="submit" value="send" disabled="disabled">   
<input id="Submit_Facebook" name="Submit_Facebook" type="submit" value="" onclick="EnableSend();">

<script type="text/javascript">
function EnableSend() {
    document.getElementById("submit").disabled = false;
}
</script>

Upvotes: 2

Related Questions