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!

Dropdown

Status
Not open for further replies.

SteveD73

Programmer
Jan 5, 2001
109
GB
Hello

How can I set the value of a dropdown list?

Thanks
 
If you want to set the value of a text option use the tag VALUE= in the OPTION tag... EG:

<OPTION VALUE=3>OPTION 3</OPTION>

If you want to define which option is selected by default, use the keyword SELECTED in the option tag... EG:

<OPTION SELECTED>OPTION 1</OPTION>

Hope this helps

G -GTM Solutions, Home of USITE-
-=
 
Not sure if this is what you are looking for but its kind of cool none the less.

This will work if you want to auto populate update a drop down list box using information stored in a database. It's not the prettiest way to do it but it works.

<%
Option Explicit
Response.Expires = -1000

Dim Conn
Dim oRS
Dim sConnection
Dim sSQL

Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
sConnection = &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; & _
&quot;Data Source=&quot; & Server.MapPath(&quot;Path to my database&quot;) & &quot;;&quot; & _
&quot;Persist Security Info=False&quot;
Conn.Open(sConnection)

%>


<SELECT NAME=&quot;EMPLOYEE&quot; SIZE=&quot;1&quot;>
<%

sSQL = &quot;SELECT * FROM employee&quot;

Set oRS = Conn.Execute(sSQL)

' -- Loop through the employee records in the Recordset Object until End Of File
Do While Not oRS.EOF

%>

<option value=&quot;<%= oRS(&quot;employee_name&quot;) %>&quot;><%= oRS(&quot;employee_name&quot;) %></option>

<%

' -- Move to next employee record
oRS.MoveNext

' -- Continue looping
Loop
%>
</Select>

<%
Conn.Close
Set oRS = Nothing
Set Conn = Nothing

%>

</Select>
<input type=&quot;submit&quot; value=&quot;Submit&quot;>
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top