jQuery in Action, 2nd edition*
The moose likes HTML, CSS and JavaScript and the fly likes howto initial select in option ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "howto initial select in option ?" Watch "howto initial select in option ?" New topic
Author

howto initial select in option ?

Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
hi good day,

if i have an option as show


and i would like to set the index from very beginning for the option(eg nload)

how to i set it ? say if i would like to set value3 as default selected item
in javascript, can someone please show me ?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
http://www.coderanch.com/t/118741/HTML-JavaScript/Selecting-value-select-tag
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
eric , it must use a for loop to check the value? we can't set it by just giving the value ?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Did you try?

Eric
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
eric, i try on this basic sample, but i can't call the value


it give me error "options is null or not an object"

what mistake occur in my code ?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
thank you eric for the example
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: howto initial select in option ?
 
Similar Threads
JSP select with multiple options
Firefox doesn't show background color for selected option
Dropdown select box - Setting the default display value
Ajax : how to replace another option list?
Getting an Option object from Select Object using JavaScript