Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 June 21st, 2006, 11:53 AM
Registered User
 
Join Date: Jun 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default populate dropdown from sql

Hello forum!,
I'm new to ASP/forum and have to modify the code below. When the app is ran you get a list of checkboxes to choose from which passes values to crystal reports. All I need to do is change those checkboxs to dropdowns. Can someone give me some assistance here??

<%@ Language=VBScript %>
<% Option Explicit %>
<%
Dim dFrom, dTo
Dim iIncidentID
Dim aTypeID, aStatusID,aPayGradeID

aTypeID = Split(Request.Form("chkTypeID"), ",")
aStatusID = Split(Request.Form("chkStatusID"), ",")
aPayGradeID = Split(Request.Form("chkPayGradeID"), ",")

iIncidentID = 0

%>
<html>
<head>
<title>Test Report</title>
</head>
<body>
<form name="frmSelect" action="rep1.aspx" method="post" onsubmit="return fnCheck();">
<table border="0">
      <td valign="top">
      <b>STATUS</b>
      <table cellpadding="0" cellspacing="0">
<%
sbPrintChoices ROOT_ID, CAT_STATUS, 0, aStatusID
%>


<b>STATUS2</b>
<table>
<%
sbPrintChoices ROOT_ID, CAT_STATUS2, 0, aStatus2ID
%>
</table>




<%
Sub sbPrintChoices(ByVal iParentID, ByVal iCat, ByVal iPad, ByRef aID)
  Dim aChild, i, sCat, sID

  Select Case iCat
  Case CAT_STATUS
    sCat = "Status"
    sSQL = "SELECT tbl_Status.sta_StatusID, tbl_Status.sta_Status, tbl_SubStatus.sst_Type, tbl_SubStatus.sst_Multiple, tbl_SubStatus.sst_Type " & _
  "FROM tbl_Status INNER JOIN tbl_SubStatus ON tbl_Status.sta_StatusID = tbl_SubStatus.sst_ChildID " & _
           "WHERE tbl_SubStatus.sst_ParentID = " & iParentID & " ORDER BY tbl_Status.sta_StatusID"

  Case CAT_PAYGRADE
   sCat = "PayGrade"
   sSQL = "SELECT pay_PayGradeID, pay_PayGrade, 0 AS theType FROM tbl_Paygrade ORDER BY pay_PayGradeID"


          End Select

  openRst sSQL, "", "", "", "", ""
  If Not oRst.EOF Then aChild = oRst.GetRows
  closeRst

  If IsArray(aChild) Then
    For i = LBound(aChild, 2) To UBound(aChild, 2) %>

       <tr><td style="padding-left:<%=iPad%>px;">

 <% If aChild(CLD_TYPE, i) <> 2 Then %>

            <input type=checkbox id="chk<%=sCat%>ID" name="chk<%=sCat%>ID" value="<%=aChild(CLD_ID, i)%>"


        <%
        If IsArray(aID) Then
          For Each sID In aID
            If CInt(sID) = aChild(CLD_ID, i) Then Response.Write " checked"
          Next
        End If
        Response.Write "/> " & aChild(CLD_NAME, i)
        Response.Write "<br/>" & vbCrLf
      Else
        Response.Write " [u]" & aChild(CLD_NAME, i) & "</u><br/>" & vbCrLf
      End If
        Response.Write " </td></tr>" & vbCrLf

      If iCat = CAT_STATUS Or iCat = CAT_TYPE Then _
        sbPrintChoices aChild(CLD_ID, i) , iCat, iPad + 10, aID

       Next

    End If
End Sub
%>



Sorry If this is really long. I believe the problem lies within the sbprintchoices, but not %100 sure.

Any help is greatly appreicated!
Thanks,
d





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Script to populate TBH database motemape BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 May 25th, 2007 04:42 AM
Populate Array with SQL query string nicoleh Classic ASP Databases 3 July 6th, 2005 02:55 PM
populate listbox from SQL server Stanny Access 1 May 30th, 2005 08:11 AM
dropdown save into sql table noor ASP.NET 1.0 and 1.1 Basics 3 January 3rd, 2005 12:36 AM
Can't Populate Multiple Dropdown Lists with DSO nick8245 Javascript 4 September 24th, 2003 08:55 AM





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