Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    deactivating button

    help everyone...

    have a problem with deactivating buttons. i wanted to create a js that would activate a second button if the first button is clicked.

    the sample below would activate the button if the correct text input is given (though written in vbscript.. guess they are almost the same)


    <INPUT name="edit1" size="50">
    <SCRIPT type="text/vbscript">
    Sub edit1_changed()
    If edit1.value = "abc" Then
    button1.enabled = True
    Else
    button1.enabled = False
    End If
    End Sub
    </SCRIPT>

    can anyone pls help me make a script in js replacing the text input to button so the second button would be activated...

    your help would be greatly appreciated... thank you.

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,519
    Thanks
    3
    Thanked 507 Times in 494 Posts
    this is a JavaScript forum

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
    
    <INPUT name="edit1" size="50" onblur="edit1_changed(this,'button1','abc');" >
    <input type="button" id="button1" value="Test" onclick="alert('enabled');"  />
    <SCRIPT type="text/javascript">
    
    function edit1_changed(obj,id,val){
     var zxcobj=document.getElementById(id);
     zxcobj.removeAttribute('disabled');
     if (obj.value==val){
      zxcobj.setAttribute('disabled','disabled');
     }
    }
    </SCRIPT>
    
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •