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

dynamically select dropdown option

Status
Not open for further replies.

sqoti

Programmer
Dec 1, 2000
50
US
Please Help if you can. I am working on a site that allows searches from many places, mainly from one search box in a top banner, but also from some pages located within the site. On one of my pages I allow a search that only searches that pages' content. This is built in, the user knows it is just searching that page, and it does it automatically. When the search results come up, I have a dropdown list that shows the different pages that are searchable(subsearch). The user has the option to pick that page to search on from the dropdown.

This is what I would like to do. When a search is performed from page A, I want the results page to focus on page A in the dropdown. Same situation goes for any page a user searches. If user is searching Page X, I want page X to show up in the dropdown list on the results page.

I have tried the following, but it doesn't work for some reason.

In the results page, I have a onload to perform a function that has

document.formname.dropdownname.options[indexofPage].selected = true;

If you know of a way to make this work you will be a life saver.

Thanks in advance!!!!

Sqoti
 
try

document.formname.dropdownname.selectedIndex = indexOfDesiredOption;




=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Thanks Jeff,

I figured out what I was doing before was correct, but had soem syntax errors in it. I appreciate your help though and I learned a different way to code that...


Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top