michellerobbins56
Programmer
Hi there
I have created a drop down list which is called User Type. The data in this drop down list is populated by data in a database. This is all fine. However my problem is not the saving to the database (this works fine), my problem is displaying the 'selected' value and all the other items in the list. Here is my code (I've copied and pasted it from notepad, not sure how to make it more readable I'm afraid):
'-----------------------------------------
Dim rsUserType, LstUserType
Set rsUserType = Server.CreateObject("ADODB.Recordset")
strSQL = "Select user_type_id, user_type from tuUserType ORDER BY user_type"
rsUserType.Open strSQL, cnnConn, 1, 4
rsUserType.MoveFirst
If strUserType="0" then 'nothing selected in register form
LstUserType = LstUserType & "<option value='0' SELECTED>Please select</option>"
While not rsUserType.EOF
LstUserType = LstUserType & "<option value='" & rsUserType("user_type") & "'>" & rsUserType("user_type") & "</option>"
rsUserType.MoveNext
WEND
else 'something was selected
LstUserType = LstUserType & "<option value='" & strUserType & "' selected>" & strUserType & "</option>"
While not rsUserType.EOF
LstUserType = LstUserType & "<option value='" & rsUserType("user_type") & "'>" & rsUserType("user_type") & "</option>"
rsUserType.MoveNext
WEND
end if
rsUserType.Close
ListUserType = ListUserType & "<option value='Other'>Other...</option>"
'------------------------------------
strUserType represents the value in the database for usertype.
There are three values in the database: "end user", "manufacturer" and "trade". It works fine if nothing has been selected in the database: the text "please select" is displayed. However if a value has been selected I find that value is displayed (because it is the 'selected' value) but it is also displayed a second time when I display the rest of the items in the list. My question is how can I display the rest of the items in the list APART from the selected value? For example if "manufacturer" was selected this would be displayed as the selected value (which is what I want) but then the rest of the list has "end user", "manufacturer" and "trade" so you can see "manufacturer" is displayed twice which is not what I want.
Thank you very much for any help with this problem.
I have created a drop down list which is called User Type. The data in this drop down list is populated by data in a database. This is all fine. However my problem is not the saving to the database (this works fine), my problem is displaying the 'selected' value and all the other items in the list. Here is my code (I've copied and pasted it from notepad, not sure how to make it more readable I'm afraid):
'-----------------------------------------
Dim rsUserType, LstUserType
Set rsUserType = Server.CreateObject("ADODB.Recordset")
strSQL = "Select user_type_id, user_type from tuUserType ORDER BY user_type"
rsUserType.Open strSQL, cnnConn, 1, 4
rsUserType.MoveFirst
If strUserType="0" then 'nothing selected in register form
LstUserType = LstUserType & "<option value='0' SELECTED>Please select</option>"
While not rsUserType.EOF
LstUserType = LstUserType & "<option value='" & rsUserType("user_type") & "'>" & rsUserType("user_type") & "</option>"
rsUserType.MoveNext
WEND
else 'something was selected
LstUserType = LstUserType & "<option value='" & strUserType & "' selected>" & strUserType & "</option>"
While not rsUserType.EOF
LstUserType = LstUserType & "<option value='" & rsUserType("user_type") & "'>" & rsUserType("user_type") & "</option>"
rsUserType.MoveNext
WEND
end if
rsUserType.Close
ListUserType = ListUserType & "<option value='Other'>Other...</option>"
'------------------------------------
strUserType represents the value in the database for usertype.
There are three values in the database: "end user", "manufacturer" and "trade". It works fine if nothing has been selected in the database: the text "please select" is displayed. However if a value has been selected I find that value is displayed (because it is the 'selected' value) but it is also displayed a second time when I display the rest of the items in the list. My question is how can I display the rest of the items in the list APART from the selected value? For example if "manufacturer" was selected this would be displayed as the selected value (which is what I want) but then the rest of the list has "end user", "manufacturer" and "trade" so you can see "manufacturer" is displayed twice which is not what I want.
Thank you very much for any help with this problem.