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
Member Avatar for diafol

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

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.

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.