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

Selecting Options Dynamically 1

Status
Not open for further replies.

AgentM

MIS
Jun 6, 2001
387
US
Can somebody tell me,
How can I select an Option in a Select dropdownbox on page load?

Can I use document.form.selBox.selected.value = 0?

Any help appreciated?

Thank you.
 
document.myForm.mySelect.selectedIndex = 0 -----------------------------------------------------------------
"Whether you think that you can, or that you can't, you are usually right."
- Henry Ford (1863-1947)

mikewolf@tst-us.com
 
Thank you very much more questions:-

Here's what I am doing, when a user selects a value in a form's select dropdown box the form is submitted, data is obtained and displayed. The only thing I cannot do is preserve the selected value.

How do I do that? Is there a way to link the value in the Options to the SelectedIndex

Thanks for all the help

 
Are you trying to reload the select box dynamically? This is how I do it in asp. Let me know if you need something different....

<%
set objRS = objConn.execute(&quot;SELECT valueField, descriptionField FROM myTable&quot;)

selectChoice = request(&quot;mySelect&quot;)
optionStr = &quot;<option value=''>Choose One&quot;
do while not objRS.eof
if objrs(&quot;valueField&quot;) = selectChoice then keyWord = &quot;SELECTED&quot; else keyWord = &quot;&quot;
optionStr = optionStr & &quot;<option value='&quot;& objRS(&quot;valueField&quot;) & &quot;' &quot; & keyWord & &quot;>&quot; & objRS(&quot;descriptionField&quot;)

objrs.movenext
loop
%>

<select name=&quot;mySelect&quot;><%=optionStr%></select>

-----------------------------------------------------------------
&quot;The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.&quot;
- unknown

mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top