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!

Kind of an asp/javascript crossover question

Status
Not open for further replies.

BascoBill

MIS
Jul 17, 1999
7
US
Hello all,

I am just getting my feet wet with asp (I find it a lot of fun). This is what I am trying to do - I hope someone can give me a clue about how to do it.

When my page loads, the entire page is a form for the user to fill out for the application. certain fields in this form are prepopulated with retrieved data from the db. One of these formfields on the page is for "State". It is a dropdown list on which the options are hard-coded.

What I want to be able to do is indicate the retrieved State from the db on the dropdown list when the page loads. So far I have been able to write a javascript function that loops through the "options" array and does find a match with the value from the db (I have proven this with an alert box). I have tried setting

document.form[0].state.selected==true

but that didnt have the effect that I wanted (the dropdown box on the screen still says 'Choose a state...'). Is there a way to make the screen display the correct state?

Thanks a lot for your help - this is driving me nuts..

Bill
 
once you find 'i' (the index of the state you want), just:

document.forms[0].state.value= i;

it's either that or:

document.forms[0].state.selectedIndex = i;

:)
paul
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top