I created a user registration page using ASP and Dreamweaver, I tried to create a drop down box filled with options from a database. I only wanted the box to contain one of each option but it contains every one, one for each user when i view this in firefox. when i view the page in explorer the box does not contain anything and the options are all listed below the box.

part of the code is underlined, when i hover over it i get an message 'The title attribute of the SELECT tag is not supported [Netscape Navigator 4.0, Netscape Navigator 6.0]' I do not know what this error means, is this why the drop down box won't work??

heres part of my code, the line in red is the line that is underlined:-

Dim rs_accesslevel
Dim rs_accesslevel_numRows

Set rs_accesslevel = Server.CreateObject("ADODB.Recordset")
rs_accesslevel.ActiveConnection = MM_dbtest_STRING
rs_accesslevel.Source = "SELECT accesslevel FROM users"
rs_accesslevel.CursorType = 0
rs_accesslevel.CursorLocation = 2
rs_accesslevel.LockType = 1
rs_accesslevel.Open()

rs_accesslevel_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>register</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<h3>Please register new user below:-</h3>
<form action="<%=MM_editAction%>" method="POST" name="formregister" id="formregister">
  <table width="528" height="136" border="1">
    <tr>
      <td width="153">username</td>
      <td width="359"><input name="txtusername" type="text" id="txtusername" size="50"></td>
    </tr>
    <tr>
      <td>password</td>
      <td><input name="txtpassword" type="password" id="txtpassword" size="20"></td>
    </tr>
    <tr>
      <td>Access level</td>
      <td><select name="accesslevel" title="<%=(rs_accesslevel.Fields.Item("accesslevel").Value)%>"><input name="txtaccesslevel" type="text" id="txtaccesslevel" size="50">
        <%
While (NOT rs_accesslevel.EOF)
%>
        <option value="<%=(rs_accesslevel.Fields.Item("accesslevel").Value)%>" <%If (Not isNull((rs_accesslevel.Fields.Item("accesslevel").Value))) Then If (CStr(rs_accesslevel.Fields.Item("accesslevel").Value) = CStr((rs_accesslevel.Fields.Item("accesslevel").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(rs_accesslevel.Fields.Item("accesslevel").Value)%></option>
        <%
  rs_accesslevel.MoveNext()
Wend
If (rs_accesslevel.CursorType > 0) Then
  rs_accesslevel.MoveFirst
Else
  rs_accesslevel.Requery
End If
%>

Thanks!
Any ideas gretaly apprecitated!

GLT

2 things:

1. Title is not a w3c standardized attribute for the SELECT tag. Don't use it
http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.6

2. You have an INPUT tag nested into your SELECT tag

<td><select name="accesslevel" title="<%=(rs_accesslevel.Fields.Item("accesslevel").Value)%>">[B]<input name="txtaccesslevel" type="text" id="txtaccesslevel" size="50">[/B]
        <%

Move this above or below the SELECT closing tag

Hi, Thanks for getting back to me.

I moved the input line above and below the select bit but that just created an input box above or below the drop down box depending where i put it.

Any other ideas?? or where exactly do you mean to put it??

Thanks!

GLT

Perhaps I may be confused with the question, but the SELECT element is a dropdown list by nature. The INPUT element is another form element and the inclusion of it within the SELECT element is why you are seeing odd results. I'm thinking you are trying to make a combo box. I'd really just remove it alltogether.

If you are looking to make a combo box where you type and find the item in a list, that's a different story and would require different code. Presumably, you would want to place the INPUT element directly above the SELECT element, but you would require JavaScript events to search the list. You would also need DHTML if you wanted the list to open and close like a combo box.

I forgot one other item in the previous post. Use the DISTINCT qualifier in your SQL statement to avoid the duplicate entries. rs_accesslevel.Source = "SELECT [B]DISTINCT[/B] accesslevel FROM users"

try following

<td><input value="<%=(rs_accesslevel.Fields.Item("accesslevel").Value)%>" name="txtaccesslevel" type="text" id="txtaccesslevel" size="50">
<select name="accesslevel">
        <%
While (NOT rs_accesslevel.EOF)
%>
        <option value="<%=(rs_accesslevel.Fields.Item("accesslevel").Value)%>" <%If (Not isNull((rs_accesslevel.Fields.Item("accesslevel").Value))) Then If (CStr(rs_accesslevel.Fields.Item("accesslevel").Value) = CStr((rs_accesslevel.Fields.Item("accesslevel").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(rs_accesslevel.Fields.Item("accesslevel").Value)%></option>
        <%
  rs_accesslevel.MoveNext()
Wend
%>
</select>
<%
If (rs_accesslevel.CursorType > 0) Then
  rs_accesslevel.MoveFirst
Else
  rs_accesslevel.Requery
End If
%>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.