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 3 of 3
  1. #1
    Join Date
    Feb 2007
    Location
    Essex, England
    Posts
    1,392
    Tokens
    0

    Latest Awards:

    Default Duno what to call it :P

    I've got this JS function for my forms when they are focused on and off. Say I fiddle with it, and change function names or whatever is it logical to change:

    HTML Code:
    <input type="text" name="text" value="Text Input" class="normal" onFocus="focusIN(this)" onBlur="blurIN(this)" />
    to:

    PHP Code:
    <?php

    $do 
    "onFocus=\"focusIN(this)\" onBlur=\"blurIN(this)\"";

    ?>
    <input type="text" name="text" value="Text Input" class="normal" <?= $do ?> />
    ..?

    Or is there an easier way of doing so, or should I just not bother
    (Baring in mind that it will be used for more than one form item)


  2. #2

    Default

    I prefer seperating HTML and Javascript because it allows me to manage it easier I also prefer javascript frameworks because they are more cross-browser compatible. You can use the following..
    Code:
    $(document).ready(function(){
      $('input[name="text"]').focus(function(){
        // Do something when focused
      });
    
      $('input[name="text"]').blur(function(){
        // Do something when blurred
      });
    });
    in conjunction with
    Code:
    <input type="text" name="text" value="Text Input" class="normal">
    Now to me that's an easier way to do it and an easier way to manage too. But it all comes down to preference, also just do you know you need the jQuery library for my example to work. I hope this helps answer your question.

    Live example - http://pastebin.me/492dc7be599ec

  3. #3
    Join Date
    Feb 2007
    Location
    Essex, England
    Posts
    1,392
    Tokens
    0

    Latest Awards:

    Default

    Hm, I might give that a go. Will probably be useful for anything else I add on. Cheers, +rep.
    [Gota spread]


Posting Permissions

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