HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 6th, 2000, 11:36 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
I have a situation where I know the value of an option I want selected but not the index.

IE will allow me to select by setting options.value= the value I want, but Netscape doesn't allow this. I know the proper way is to set selectedIndex but I don't know the index.

How can I get the index of the option from the value?

Reply With Quote
  #2  
Old October 7th, 2000, 03:42 PM
HyperWhiz HyperWhiz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 4 HyperWhiz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm not quite sure if I understand your problem... but if you want a certain option seleted by default, just use the SELECTED attribute of the OPTION tag:

<OPTION VALUE="01" SELECTED>

But, if you want to get the selectedIndex, use this format:

var eSelected = document.formname.select name.selectedIndex;

and then this to get the value of the option that is selected.

var eVarSelected = document.signup.selectengine.options[eSelected].value;

Hope this helps you come up with a solution.

HyperWhiz

Reply With Quote
  #3  
Old October 8th, 2000, 04:06 PM
tvanbart tvanbart is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 35 tvanbart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
If you know the value of the item you want selected, why not loop through the options, testing each value until you find what you want? The index where you find it will be the index that you need selected.
(Sorry, a little too late for a code example, I guess you can work it out from there (and if not, feel free to ask again))

Hope this helps, Ton


Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > getting option index from option.value


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT