0

I need to set a default value in a combo box and i cannot figure it out. Sorry I am new to Javascript (and web development). I am not really asking someone to write the code for me but point me in the right direction.

Function BuildTechnicianListDropDown(strSelectBoxName, intLockID)

    Dim rst, cmd, cnn

    Set cnn = Server.CreateObject("ADODB.Connection")
    cnn.Open strDSN, strDSNUserName, strDSNPassword

    Set cmd = Server.CreateObject("ADODB.Command")

    cmd.ActiveConnection = cnn
    cmd.CommandText = "SPTechnicianListGet"
    cmd.CommandType = adCmdStoredProc


    Set rst = Server.CreateObject("ADODB.Recordset")
    'Set rst = cmd.Execute
    rst.Open cmd,,adOpenStatic,adLockReadOnly

    Response.Write "<select name=" & Chr(34) & strSelectBoxName & Chr(34) & ">" & Chr(13)
    Response.Write "<option value=" & Chr(34) & Chr(34) & ">" & "</option>" & Chr(13) 
    If not(isnull(intLockID)) Then
        While not rst.eof
            If rst("UserID") = intLockID Then
                Response.Write "<option value=" & Chr(34) & rst("TechnicianID") & Chr(34) & "selected=selected>" & rst("LastName") & ", " & rst("FirstName") & "</option>" & Chr(13)  
            Else
                Response.Write "<option value=" & Chr(34) & rst("TechnicianID") & Chr(34) & ">" & rst("LastName") & ", " & rst("FirstName")  & "</option>" & Chr(13)  
            End If
            rst.MoveNext
        wend

    Else
        While not rst.eof
            Response.Write "<option value=" & Chr(34) & rst("TechnicianID") & Chr(34) & ">" & rst("LastName") & ", " & rst("FirstName") & "</option>" & Chr(13)   
            rst.MoveNext
        wend
    End If  

    Response.Write "</select>" & Chr(13)

    Set cmd = Nothing
    Set rst = Nothing
    cnn.Close
    Set cnn = Nothing

End Function

Edited by diafol: moved to webdev

2
Contributors
2
Replies
10
Views
3 Years
Discussion Span
Last Post by djblois
0

New to js? Isn't this ASP? You posted the right snippet?

0

Sorry I misquoted this is ASP. I am new to Web development sorry. This is the right code - it is what makes the combobox that I need to set a default value for. I basically understand the code but I cannot figure out how to set a default value.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.