www.webdeveloper.com
Results 1 to 4 of 4

Thread: SELECT equivalent of an INPUT defaultValue?

  1. #1
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582

    SELECT equivalent of an INPUT defaultValue?

    Hello, everyone.

    Interesting question: Does a form SELECT have an equivalent to a form INPUT type="text" defaultValue?

    For example: if an input field has a value of "Click Here" when a form first loads, and is set to become "" (blank) when focus is put on it, you can have JavaScript set the value to defaultValue ("Click Here") upon blur if nothing was typed.

    Is there an equivalent for a SELECT option? If a different option is selected, can you compare that new option selectedIndex value to the original option selectedIndex value that was when the form first loads?

    Thanks,
    |||||
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long

    ^_^

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,373
    Can you provide a description where this could be used?
    A small example of what it is that you are trying to do?

  3. #3
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    I was trying to get fancy-shmancy with some validation.

    Basically, there is a select that contains an initial option (value 0, display "All Reports") and that is followed by a db query of (value employee ids, display employee name) so a supervisor can view an individual's record. I just wanted to keep the submit button disabled until a different option is selected. That's why I wanted to compare current selectedIndex against original selectedIndex (when form first loads.)

    Sadly, that function was causing some conflict with something else, so just a few minutes ago it was scrapped. I was just on my way here to cancel the request.
    |||||
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long

    ^_^

  4. #4
    Join Date
    Feb 2006
    Posts
    2,927
    an option has an option.defaultSelected value of true if it has the attribute 'selected' in the html source, otherwise the value is false.

    You can use it to see if the user has selected something other than the original default- if you want to.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles