Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
HTML Pages with CSS and JavaScript
howto initial select in option ?
Nakata kokuyo
Ranch Hand
Posts: 472
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi good day,
if i have an option as show
<SELECT NAME="state" SIZE=0> <OPTION VALUE="value1" selected> <OPTION VALUE="value2">AL <OPTION VALUE="value3">AK </SELECT>
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
Posts: 15385
6
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
https://coderanch.com/t/118741/HTML-JavaScript/Selecting-value-select-tag
Nakata kokuyo
Ranch Hand
Posts: 472
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
eric , it must use a for loop to check the value? we can't set it by just giving the value ?
Eric Pascarello
author
Posts: 15385
6
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Did you try?
Eric
Nakata kokuyo
Ranch Hand
Posts: 472
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
eric, i try on this basic sample, but i can't call the value
function init() { var optionItem = document.forms[0].state; alert(optionItem.options[0].value) }
it give me error "options is null or not an object"
what mistake occur in my code ?
Eric Pascarello
author
Posts: 15385
6
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
<html> <head> <script type="text/javascript"> function test(){ var sel = document.forms[0].select1; alert(sel.options[0].value); sel.value = "4"; } </script> </head> <body onload="test()"> <form> <select name="select1"> <option value="1">s1</option> <option value="2">s2</option> <option value="3">s3</option> <option value="4">s4</option> </select> </form> </body> </html>
Nakata kokuyo
Ranch Hand
Posts: 472
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
thank you eric for the example
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Firefox doesn't show background color for selected option
JSP select with multiple options
Getting an Option object from Select Object using JavaScript
Dropdown select box - Setting the default display value
Ajax : how to replace another option list?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
More...