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

Dynamic Selects/Options

Status
Not open for further replies.

Loon

Programmer
May 24, 2000
100
GB
Hi,

I have a page that creates some dynamic options for a
Code:
<select>
. The options displayed in this
Code:
<select>
are dependent on another
Code:
<select>
which has fixed options.

My problem is that the page these reside on seems to finish loading prior to the arrays of options being completed. This means that I can't seem to get the correct dynamic options to start with, I have to select something from the permanent
Code:
<select>
in order to get the right options set in the dynamic
Code:
<select>
.

I've tried doing stuff with onload=&quot;&quot; but that doesn't seem to help - any ideas anyone?

Cheers
L00N
 
UPDATE!!

Well I re-examined the onload way of doing things and this time it seems to work! I must have been doing something silly.

However, I am still having a problem where I want to set the selectedIndex of the dynamic
Code:
<select>
but seem to be unable - the first
Code:
<option>
is selected as default...

Can I not just use:

Code:
myform.myselect.selectedIndex = optionToBeSelected;

as part of my
Code:
init()
function I call from a
Code:
<BODY onload=&quot;init();&quot;>
 
If that wasn't working for you, try:

Code:
myform.myselect.option[optionToBeSelected].selected = true;

'hope that helps.

--Dave
 
Many thanks!
That would appear to be the way to do it!

Cheers!
Loon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top