yet another disable the submit button javascript question.

Discussion in 'JavaScript' started by clipster, Apr 17, 2009.

  1. #1
    I'm a total idiot with javascript.

    I need to disable a submit button when any one of 4 text fields (text area or input type=text types) is changed.

    scenario... data pulled from db prefills the form elements. If user changes any of the value=' saved text from db ' displayed on the page, the submit button is disabled.

    I have two separate submit buttons, one named 'changedata', the other named 'submit'. It's the one named submit that must be disabled if the user changes any of the data on this form.

    I have spent too many hours this evening looking for something that works, but heck, I can't even get my submit button to be active even with `disabled=false` attribute (I was just testing ff3 - having the word disabled anywhere in the <input type=submit.... > automatically disables that button. I have no idea what to do.

    How much $$ for a solution?
    Thanks in advance.
     
    clipster, Apr 17, 2009 IP
  2. conanite

    conanite Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What do you need the submit button for if it's not going to be used? I mean, usually there's no point in submitting a form if the user *hasn't* changed anything; so why put it there in the first place?
     
    conanite, Apr 18, 2009 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    I would agree with conanite - maybe you could describe what you want the form to do in more detail - it might be possible to do this some other way.

    For instance, it should be possible to do different things depending on what has been done to the form, with just one submit-button. (Eg: a user loads the form, doesn't change anything -> do A. A user changes one or more fields -> do B).
     
    PoPSiCLe, Apr 18, 2009 IP
  4. marty

    marty Peon

    Messages:
    154
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Disable Submit</title>
    <script language="JavaScript">
    function disableButton(){
    var submitObject = document.getElementById("submit")
    submitObject.disabled = true
    }
    </script>
    </head>
    <body>
    <input onkeydown="disableButton()">
    <input id="submit" type="Submit">
    </body>
    </html>
     
    marty, Apr 20, 2009 IP