Default input

Discussion in 'HTML' started by Zack, May 8, 2006.

  1. Zack

    Zack Guest

    How do I set an input to be default? I have a search engine but to input
    boxes above it and would like search box selected by default.

    Thanks,
    Zack
     
    Zack, May 8, 2006
    #1
    1. Advertising

  2. Zack wrote:

    > How do I set an input to be default?


    Normally your question would be answered by saying that you specify the
    default value for a text input field in the value="..." attribute.

    > I have a search engine but to input
    > boxes above it and would like search box selected by default.


    Apparently, you meant to ask how to make a text input field _focused_
    when a page is entered.

    The short answer is: Don't.

    The longer answer is: You shouldn't, because the user may enter some
    input into the field _before_ your client-side script manages to focus
    on it. (There's no other way to focus on it than client-side scripting.)
    Now imagine yourself typing "foobar" and having just "bar" entered,
    since after you had typed "foo", the field was focused, thereby
    selecting the text in it, and then the characters "bar" _replaced_ the
    old content.

    If you _still_ want to do that, use the JavaScript function onfocus(),
    see http://www.cs.tut.fi/~jkorpela/forms/javascript.html#focus
     
    Jukka K. Korpela, May 8, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. micky

    default.mspx or default.do

    micky, Dec 16, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    496
    Andrew Robinson
    Dec 17, 2005
  2. Gaetan
    Replies:
    3
    Views:
    1,432
    Juan T. Llibre
    Feb 14, 2006
  3. C Gillespie
    Replies:
    3
    Views:
    413
    Peter Hansen
    Mar 22, 2005
  4. Max
    Replies:
    2
    Views:
    485
    Joe Kesselman
    Aug 1, 2006
  5. desktop
    Replies:
    2
    Views:
    462
    Victor Bazarov
    Jun 6, 2007
Loading...

Share This Page