Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5
  1. #1
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default JavaScript Help =]

    Ok,

    Im learning more javascript and so far, I can do most things, but only to do them in the onclick attribute using 'this'

    Say i wanted a button that would enable fields in a form using a function, how would i do this?

    For example
    HTML Code:
    <head>
    <script type="text/javascript">
    function enable()
    {
    document.form1.field1.disabled = 'false';
    document.form1.field2.disabled = 'false';
    }
    </script>
    </head>
    <body>
    <form name="form1">
    <input type="text" disabled="disabled" name="field1" />
    <input type="text" disabled="disabled" name="field2" />
    <input type="button" onclick="enable()" />
    </form>
    </body>
    Thanks for any help
    Coming and going...
    Highers are getting the better of me

  2. #2
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    Little bit of fiddling:
    (You where along the right lines generally)
    HTML Code:
    <html>
    <head>
    <script type="text/javascript">
    function enable()
    {
    document.form1.field1.disabled = false;
    document.form1.field2.disabled = false;
    }
    </script>
    </head>
    <body>
    <form name="form1">
    <input type="text" disabled="disabled" name="field1" />
    <br />
    <input type="text" disabled="disabled" name="field2" />
    <br />
    <input type="button" onclick="enable()" value="Enable" />
    </form>
    </body>
    </html>
    i've been here for over 8 years and i don't know why

  3. #3
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    lol, i just coded form as example, (thats why i didnt put the line breaks in )

    But thanks for help

    Il try that now
    Coming and going...
    Highers are getting the better of me

  4. #4
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    Just a little extension for if you wanted to enable and disable using one button you could do this

    HTML Code:
    <html>
    <head>
    <script type="text/javascript">
    function enable()
    {
    d = document.form1.field1.disabled;
    
    if(d == false){
    
    document.form1.field1.disabled = true;
    document.form1.field2.disabled = true;
    
    }else{
    
    document.form1.field1.disabled = false;
    document.form1.field2.disabled = false;
    
    }
    
    
    }
    </script>
    </head>
    <body>
    <form name="form1">
    <input type="text" disabled="disabled" name="field1" />
    <br />
    <input type="text" disabled="disabled" name="field2" />
    <br />
    <input type="button" onclick="enable()" value="Enable" />
    </form>
    </body>
    </html>

  5. #5
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Oooh

    Ty Jake
    +REP to both - Have to spread :|

    -Really ought to learn javascript lol
    Coming and going...
    Highers are getting the better of me

Posting Permissions

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