Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 04:43 AM
Select and Recordset question iacon Beginning VB 6 4 June 24th, 2006 10: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



All times are GMT -4. The time now is 10:37 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.