Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2006, 12:59 PM
Registered User
 
Join Date: Feb 2006
Location: Tamworth, Staffs, United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Fill select box and select recordset value

Hi,

I have a problem selecting a value from a recordset. The code i have currently populates the select box but i would like to select a value depending on my other recordset.

Its actually an update procedure im doing, but i want to return a recordset in an editable format with select boxes.

<%
    Set oRs=Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT DISTINCT manager FROM tblManager ORDER BY manager"
    oRs.Open strSQL

    Do while not oRs.EOF
        if Request.Form("selmanager") = oRs("manager") then 'if this is the selected one then display as selected
            Response.Write "<OPTION VALUE = '" & oRS ("manager") & "' SELECTED>"
            Response.Write oRs("manager") & "</Option>"
            oRs.MoveNext
        else
            Response.Write "<OPTION VALUE = '" & oRs ("manager") & "'>"
            Response.Write oRs("manager") & "</Option>"
            oRs.MoveNext
        end if
    loop
    %>

this code fills my select box fine, but im strugling when i want to select a default value.

M Dayton
 
Old February 20th, 2006, 06:41 PM
Authorized User
 
Join Date: Feb 2006
Location: Verona, Italy, Italy.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

... because you take that ( oRs.MoveNext ) behind the condition ?


<%
    Set oRs=Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT DISTINCT manager FROM tblManager ORDER BY manager"
    oRs.Open strSQL

    Do while not oRs.EOF
        if Request.Form("selmanager") = oRs("manager") then 'if this is the selected one then display as selected
            Response.Write "<OPTION VALUE = '" & oRS ("manager") & "' SELECTED>"
            Response.Write oRs("manager") & "</Option>"

        else
            Response.Write "<OPTION VALUE = '" & oRs ("manager") & "'>"
            Response.Write oRs("manager") & "</Option>"
        end if

    oRs.MoveNext
    loop
    %>

Steweb




I don’t Speak English very well, excuse me !

www.steweb.net




Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare select box Dj Kat Javascript How-To 4 November 15th, 2007 11:03 AM
Select box ? mikedeepak Classic ASP Professional 0 July 20th, 2006 03:43 AM
Select and Recordset question iacon Beginning VB 6 4 June 24th, 2006 09:37 AM
multicolored List Box or Select Box sasidhar79 Javascript 1 February 15th, 2005 01:47 AM
select box/List box alphabetic sort sasidhar79 Javascript How-To 3 November 10th, 2004 03:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.