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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I reset a list menu? 1

Status
Not open for further replies.

Microbe

Programmer
Oct 16, 2000
607
AU
Hey folks,

I have a form to edit a series of rows. On each row there is a list menu that displays an option based on a mySQL value.

I have added a "clear row" button calling a Javascript function which works perfectly...almost.

How can I get the list menu to reset from the selected option to "choose option" which is the default.

I have tried
Code:
document.getElementById("field").selectedIndex = document.getElementById("field")[0]
and a few variations on that without success. Have also tried the "Google Search For Almost Everything", no luck there either.

Thanks in advance.

Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
We're talking about a [tt]<select>[/tt] control? If "Choose Option" is the first option then:
Code:
document.getElementById("field").selectedIndex = 0;

or
Code:
document.getElementById("field").options[0].selected = true;

should work.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Enable Apps
 
I have given you a star, not because your solution was right (which it was) but more because it led me to why it wasn't working.

(Writes 100 times on board) Next time I will remember to include the "id=" parameter...sigh...

Thanks

Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top