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!

Insert Blank entry at top of drop down

Status
Not open for further replies.

ter79

IS-IT--Management
Jul 11, 2001
106
US
I have a drop down box being populated from SQL data, how can I make the first line in the box blank, no value or text so it makes the user choose something or make the first line something like "Please select report"

Here is the code that I'm using to populate the drop down

Sub BuildOfc
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Source = "uspSel_SalesOfc(" & urlRID & ")"
rs.ActiveConnection = GetConn()
rs.Open

Response.Write &quot;<SELECT class=&quot;&quot;180box&quot;&quot; name=ofclist>&quot;
Do While Not rs.EOF
Response.Write &quot;<OPTION value=&quot; & quot & rs(&quot;ID&quot;) & quot & &quot;>&quot; & rs(&quot;Name&quot;) & &quot;</OPTION>&quot;
rs.MoveNext
Loop
Response.Write&quot;</SELECT>&quot;
rs.Close
Set rs = Nothing
End Sub


Thanks in advance
 
Sub BuildOfc
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Source = &quot;uspSel_SalesOfc(&quot; & urlRID & &quot;)&quot;
rs.ActiveConnection = GetConn()
rs.Open

Response.Write &quot;<SELECT class=&quot;&quot;180box&quot;&quot; name=ofclist>&quot;
RESPONSE.WRITE &quot;<OPTION></OPTION>&quot;
Do While Not rs.EOF
Response.Write &quot;<OPTION value=&quot; & quot & rs(&quot;ID&quot;) & quot & &quot;>&quot; & rs(&quot;Name&quot;) & &quot;</OPTION>&quot;
rs.MoveNext
Loop
Response.Write&quot;</SELECT>&quot;
rs.Close
Set rs = Nothing
End Sub
 
You already step in to correct way. you just need to manipulate a little bit.
Here's i quote some of your codes :
Code:
..............
.............
rs.Open
    Response.Write &quot;<SELECT class=&quot;&quot;180box&quot;&quot; name=ofclist>&quot;

    Response.Write &quot;<OPTION value='' selected >Please select Report</OPTION>&quot;

        Do While Not rs.EOF
            Response.Write &quot;<OPTION value=&quot; & quot & rs(&quot;ID&quot;) & quot & &quot;>&quot; & rs(&quot;Name&quot;) & &quot;</OPTION>&quot;
            rs.MoveNext
        Loop
    Response.Write&quot;</SELECT>&quot;
    rs.Close

That's all. Easy rite ??
then in your client script (javascript, or VB script) you just need to validate whether users have chosen any report type by examining the value of
Code:
ofclist
.

Hope it helps

*JJ* [spin]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top