How to know the option  Id from a Select List by its value?
ex
       some text1  //id = 0
       some text2  //id = 1   
       some text3  //id = 2
 I need something like $(''test'').options[TEST_ID] but I only
have it''s value....
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Hi,> <select id="test"> > <option value="34"> some text1 </option> //id = 0 > <option value="45"> some text2 </option> //id = 1 > <option value="25"> some text3 </option> //id = 2 > </select> > > > I need something like $(''test'').options[*TEST_ID*] but I only have it''s value....Try $(''test'').selectedIndex Regards, Carl. -- TopTheTable.com - Fun and games for the World Cup 2006. It''ll get you in trouble with your boss, promise.
$(''test'').value = ''45'';
 
________________________________
From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
[mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]
On Behalf Of
Fernando
Sent: Wednesday, June 07, 2006 8:15 AM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: [Rails-spinoffs] SelectLists
 
How to know the option  Id from a Select List by its value?
ex
    <select id="test">
      <option value="34"> some text1 </option> //id = 0
      <option value="45"> some text2 </option> //id = 1   
      <option value="25"> some text3 </option> //id = 2
   </select>
 I need something like $(''test'').options[TEST_ID] but I only
have it''s
value....
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Sorry, hit send before I finished:
$(''test'').value = ''45'';
var id = $(''test'').selectedIndex;
 
Is that what you mean?
 
Greg
 
________________________________
From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
[mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]
On Behalf Of
Fernando
Sent: Wednesday, June 07, 2006 8:15 AM
To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: [Rails-spinoffs] SelectLists
 
How to know the option  Id from a Select List by its value?
ex
    <select id="test">
      <option value="34"> some text1 </option> //id = 0
      <option value="45"> some text2 </option> //id = 1   
      <option value="25"> some text3 </option> //id = 2
   </select>
 I need something like $(''test'').options[TEST_ID] but I only
have it''s
value....
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
yes selectedIndex ,solved my problemn =) tks Carl escreveu:> Hi, > >> <select id="test"> >> <option value="34"> some text1 </option> //id = 0 >> <option value="45"> some text2 </option> //id = 1 >> <option value="25"> some text3 </option> //id = 2 >> </select> >> >> >> I need something like $(''test'').options[*TEST_ID*] but I only have >> it''s value.... > > Try $(''test'').selectedIndex > > Regards, > Carl. >