Script to enable/diable button

Discussion in 'JavaScript' started by imarketing101, Jul 27, 2010.

  1. #1
    Hi,

    I need to create a simple script to enable a button on a HTML form only after a certain link is clicked on.

    Please help!

    Thanks,
    Peter
     
    imarketing101, Jul 27, 2010 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    Here is an example how you can do it:

    
    <html>
    
    <head>
      <title>Enable Button</title>
    </head>
    
    <script type="text/javascript">
    function enable_button(button_id){
        document.getElementById(button_id).removeAttribute("disabled");
    }
    </script>
    
    <body>
    
    <form method="post">
        <input type="button" id="button" name="button" value="Button" disabled="disabled" /><br />
        <a href="http://rubensargsyan.com/" target="_blank" onclick="enable_button('button');">http://rubensargsyan.com</a>
    </form>
    
    </body>
    
    </html>
    
    Code (markup):
     
    s_ruben, Jul 27, 2010 IP
  3. imarketing101

    imarketing101 Peon

    Messages:
    67
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks ruben! Worked just fine on a test page!

    I'll try the real page later.
     
    imarketing101, Jul 28, 2010 IP