Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selected property of select/option 1

Status
Not open for further replies.

LyndonOHRC

Programmer
Sep 8, 2005
603
US
I have a function that modifies the contents of the currently selected option in a select.

My last line of code is:

Code:
obj.options[SelectedRowNumber].selected == true;

However, the option is not selected when focus is returned to the select.

Any suggestions appreciated.
 
Since you know the SelectedRowNumber, just use the selectedIndex method instead:
Code:
obj.selectedIndex = SelectedRowNumber


Additionally, when assigning values to variables and objects, you need to use a single equals sign (=), a double equals sign (==) is used to check for equality.

-kaht

Looking for a puppy?

silky-icon-left.gif
[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
silky-icon-right.gif
 
That's it...

Thanks, I just couldn't see it.

BTW - yorkie owner here
 
BTW - yorkie owner here
That's cool, silkys are kinda like a poor-man's version of a yorkie [lol]

-kaht

Looking for a puppy?

silky-icon-left.gif
[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
silky-icon-right.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top