Current location: Hot Scripts Forums » Programming Languages » ASP » Query Problem with Multiple select box


Query Problem with Multiple select box

Reply
  #1 (permalink)  
Old 01-23-07, 03:39 PM
elessar elessar is offline
Newbie Coder
 
Join Date: Jan 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Query Problem with Multiple select box

Hello all,

I hope i can get some help here. Well, here goes:

I have a form that pulls category name from a database (category table). The cat names populate a multiple select box. The values of the options are:

categoryID & categoryName

Ok so far:

I have a products table with relevant columns named productID, categoryID, and productName.

What is killing me is that i CANNOT figure out how to get multple products with different categoryID's to come up from selections in the select box. I can do it with one selection, but not with 2 or more.

I have searched for the select query to no avail.

Can anyone help? Thanks in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-23-07, 05:18 PM
koncept
Guest
 
Posts: n/a
select * from table where id in ('1,2,13,45')

is that what you are after?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-23-07, 10:46 PM
elessar elessar is offline
Newbie Coder
 
Join Date: Jan 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks, koncept, yes.....but...i really dont know how to explain it other than this....

how do i get that into query?

select * from products where categoryID = ??????

this is where im stuck...I dont want to hard code the query...i want to have it take what the person choses in the multiple select and have it inserted into the query....ie:

if a person choses 3 categories from the multiple select, how do i get those values into the query?

I can do it with one value, easy enough:

select * from products where catalogID = request.form("cats")
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 01-24-07, 12:04 AM
koncept
Guest
 
Posts: n/a
if you do a response.write(request.form("cats")) does it show what you want?

if so then just change your = sign to in ( and end it with a )

"select * from products where catalogID in ('" & &request.form("cats") & "')" <-- I think dont quote me on the single quotes in there
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 01-24-07, 12:31 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Select query

OK, your saying that someone selects something from a select box and that in turn loads a value into the query and runs the query.
Well when you submit your form have its action set to :
PHP Code:

 echo("<form name\"someform\" action=\"#\" method=\"POST\">"); 

And then at the top of your page just under the <body> tag you can put something like this :
PHP Code:

$query_string $_POST["Input_Element_Name"]; 

And then your querystring would look something like this :
PHP Code:

select from products where categoryID $query_string 

If you get a match, you display the results. If you don't get a match you display an error or something else.
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 01-24-07, 09:37 AM
elessar elessar is offline
Newbie Coder
 
Join Date: Jan 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for all the help guys. I guess I should post the code of what i want so here goes :

this is the page with the multiple select box

right now it only has a standard select, but i want/need to change it to a multiple select box so customers can choose multiple categories and then display that result with quantity boxes beside each record via a repeat region.

this page works fine with one category selected but not with multiple categories. This is what i dont know how to do with the query.

The recordset "cats" populates the select box:
The recordset "prods" returns products that have a catalogID of x that is passed by querystring ( catalogID=1, etc)

The recordset "info" is just misc info about the category taken from the category table.

a live version of this current page is here

I have tried converting this single selet to a multiple select but cant get the code right to accomplish this task.

By the way, thanks for all the help so far

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Response.Expires = 60
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
%>
<!--#include file="Connections/profile.asp" -->
<%
Dim rsCats
Dim rsCats_numRows

Set rsCats = Server.CreateObject("ADODB.Recordset")
rsCats.ActiveConnection = MM_profile_STRING
rsCats.Source = "SELECT * FROM vanprods ORDER BY catalogName ASC"
rsCats.CursorType = 0
rsCats.CursorLocation = 2
rsCats.LockType = 1
rsCats.Open()

rsCats_numRows = 0
%>
<%
Dim rsProds__MMColParam
rsProds__MMColParam = "1"
If (Request.QueryString("catalogID") <> "") Then 
  rsProds__MMColParam = Request.QueryString("catalogID")
End If
%>
<%
Dim rsProds
Dim rsProds_numRows

Set rsProds = Server.CreateObject("ADODB.Recordset")
rsProds.ActiveConnection = MM_profile_STRING
rsProds.Source = "SELECT * FROM products WHERE catalogID = '" + Replace(rsProds__MMColParam, "'", "''") + "'"
rsProds.CursorType = 0
rsProds.CursorLocation = 2
rsProds.LockType = 1
rsProds.Open()

rsProds_numRows = 0
%>
<%
Dim rsInfo__MMColParam
rsInfo__MMColParam = "1"
If (Request.QueryString("catalogId") <> "") Then 
  rsInfo__MMColParam = Request.QueryString("catalogId")
End If
%>
<%
Dim rsInfo
Dim rsInfo_numRows

Set rsInfo = Server.CreateObject("ADODB.Recordset")
rsInfo.ActiveConnection = MM_profile_STRING
rsInfo.Source = "SELECT * FROM vanprods WHERE catalogId = '" + Replace(rsInfo__MMColParam, "'", "''") + "'"
rsInfo.CursorType = 0
rsInfo.CursorLocation = 2
rsInfo.LockType = 1
rsInfo.Open()

rsInfo_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 15
Repeat1__index = 0
rsProds_numRows = rsProds_numRows + Repeat1__numRows
%>
<%
'  *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

Dim rsProds_total
Dim rsProds_first
Dim rsProds_last

' set the record count
rsProds_total = rsProds.RecordCount

' set the number of rows displayed on this page
If (rsProds_numRows < 0) Then
  rsProds_numRows = rsProds_total
Elseif (rsProds_numRows = 0) Then
  rsProds_numRows = 1
End If

' set the first and last displayed record
rsProds_first = 1
rsProds_last  = rsProds_first + rsProds_numRows - 1

' if we have the correct record count, check the other stats
If (rsProds_total <> -1) Then
  If (rsProds_first > rsProds_total) Then
    rsProds_first = rsProds_total
  End If
  If (rsProds_last > rsProds_total) Then
    rsProds_last = rsProds_total
  End If
  If (rsProds_numRows > rsProds_total) Then
    rsProds_numRows = rsProds_total
  End If
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them

If (rsProds_total = -1) Then

  ' count the total records by iterating through the recordset
  rsProds_total=0
  While (Not rsProds.EOF)
    rsProds_total = rsProds_total + 1
    rsProds.MoveNext
  Wend

  ' reset the cursor to the beginning
  If (rsProds.CursorType > 0) Then
    rsProds.MoveFirst
  Else
    rsProds.Requery
  End If

  ' set the number of rows displayed on this page
  If (rsProds_numRows < 0 Or rsProds_numRows > rsProds_total) Then
    rsProds_numRows = rsProds_total
  End If

  ' set the first and last displayed record
  rsProds_first = 1
  rsProds_last = rsProds_first + rsProds_numRows - 1
  
  If (rsProds_first > rsProds_total) Then
    rsProds_first = rsProds_total
  End If
  If (rsProds_last > rsProds_total) Then
    rsProds_last = rsProds_total
  End If

End If
%>
<%
Dim MM_paramName 
%>

<%
' *** Move To Record and Go To Record: declare variables

Dim MM_rs
Dim MM_rsCount
Dim MM_size
Dim MM_uniqueCol
Dim MM_offset
Dim MM_atTotal
Dim MM_paramIsDefined

Dim MM_param
Dim MM_index

Set MM_rs    = rsProds
MM_rsCount   = rsProds_total
MM_size      = rsProds_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
  MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Record: handle 'index' or 'offset' parameter

if (Not MM_paramIsDefined And MM_rsCount <> 0) then

  ' use index parameter if defined, otherwise use offset parameter
  MM_param = Request.QueryString("index")
  If (MM_param = "") Then
    MM_param = Request.QueryString("offset")
  End If
  If (MM_param <> "") Then
    MM_offset = Int(MM_param)
  End If

  ' if we have a record count, check if we are past the end of the recordset
  If (MM_rsCount <> -1) Then
    If (MM_offset >= MM_rsCount Or MM_offset = -1) Then  ' past end or move last
      If ((MM_rsCount Mod MM_size) > 0) Then         ' last page not a full repeat region
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  ' move the cursor to the selected record
  MM_index = 0
  While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend
  If (MM_rs.EOF) Then 
    MM_offset = MM_index  ' set MM_offset to the last possible record
  End If

End If
%>
<%
' *** Move To Record: if we dont know the record count, check the display range

If (MM_rsCount = -1) Then

  ' walk to the end of the display range for this page
  MM_index = MM_offset
  While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend

  ' if we walked off the end of the recordset, set MM_rsCount and MM_size
  If (MM_rs.EOF) Then
    MM_rsCount = MM_index
    If (MM_size < 0 Or MM_size > MM_rsCount) Then
      MM_size = MM_rsCount
    End If
  End If

  ' if we walked off the end, set the offset based on page size
  If (MM_rs.EOF And Not MM_paramIsDefined) Then
    If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
      If ((MM_rsCount Mod MM_size) > 0) Then
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  ' reset the cursor to the beginning
  If (MM_rs.CursorType > 0) Then
    MM_rs.MoveFirst
  Else
    MM_rs.Requery
  End If

  ' move the cursor to the selected record
  MM_index = 0
  While (Not MM_rs.EOF And MM_index < MM_offset)
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend
End If
%>
<%
' *** Move To Record: update recordset stats

' set the first and last displayed record
rsProds_first = MM_offset + 1
rsProds_last  = MM_offset + MM_size

If (MM_rsCount <> -1) Then
  If (rsProds_first > MM_rsCount) Then
    rsProds_first = MM_rsCount
  End If
  If (rsProds_last > MM_rsCount) Then
    rsProds_last = MM_rsCount
  End If
End If

' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth

Dim MM_removeList
Dim MM_item
Dim MM_nextItem

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
  MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If

MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
  End If
Next

' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
  End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then 
  MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "")  Then
  MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
  MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
  If (firstItem <> "") Then
    MM_joinChar = "&"
  Else
    MM_joinChar = ""
  End If
End Function
%>
<%
' *** Move To Record: set the strings for the first, last, next, and previous links

Dim MM_keepMove
Dim MM_moveParam
Dim MM_moveFirst
Dim MM_moveLast
Dim MM_moveNext
Dim MM_movePrev

Dim MM_urlStr
Dim MM_paramList
Dim MM_paramIndex
Dim MM_nextParam

MM_keepMove = MM_keepBoth
MM_moveParam = "index"

' if the page has a repeated region, remove 'offset' from the maintained parameters
If (MM_size > 1) Then
  MM_moveParam = "offset"
  If (MM_keepMove <> "") Then
    MM_paramList = Split(MM_keepMove, "&")
    MM_keepMove = ""
    For MM_paramIndex = 0 To UBound(MM_paramList)
      MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)
      If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then
        MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)
      End If
    Next
    If (MM_keepMove <> "") Then
      MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
    End If
  End If
End If

' set the strings for the move to links
If (MM_keepMove <> "") Then 
  MM_keepMove = MM_keepMove & "&"
End If

MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="

MM_moveFirst = MM_urlStr & "0"
MM_moveLast  = MM_urlStr & "-1"
MM_moveNext  = MM_urlStr & CStr(MM_offset + MM_size)
If (MM_offset - MM_size < 0) Then
  MM_movePrev = MM_urlStr & "0"
Else
  MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)
End If
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!--#include file="cart/include/NC_debug.asp" -->
<!--#include file="cart/include/NC_settings.asp" -->
<!--#include file="cart/include/NebuCart.asp" -->
<!--#include file="cart/include/NC_formatting.asp" -->
<!--#include file="cart/include/NC_multi-add.asp" -->

<script language="JavaScript">

function jumptolink(what){
var selectedopt=what.options[what.selectedIndex]
window.location=selectedopt.value
}


</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}
//-->
</script>
<link rel="stylesheet" href="cart/nebucart.css">
</head>

<BODY onLoad="cacheOff()"><br>
<STYLE TYPE="text/css">
    <!-- 
    #cache {
   position:absolute; top:300px; left=:300px; z-index:10; visibility:hidden;
    }
    -->
    </STYLE>
    <!--
    Lines above are creating a layer which show a message
    displaying the 'PLEASE WAIT ... ' message
    -->
    
<SCRIPT LANGUAGE="JavaScript">
    ver = navigator.appVersion.substring(0,1)
    if (ver >= 4)
    	{
    	document.write('<DIV ID="cache"><TABLE WIDTH=400 BGCOLOR=#000000 BORDER=0 CELLPADDING=2 CELLSPACING=0><TR><TD ALIGN=center VALIGN=middle><TABLE WIDTH=100% BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN=center VALIGN=middle><FONT FACE="Arial, Verdana" SIZE=4><B><BR>LOADING, PLEASE WAIT...<img src="images/spinner.gif"><BR><BR></B></FONT></TD> </TR></TABLE></TD> </TR></TABLE></DIV>');
    	var navi = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4);
    	var HIDDEN = (navi) ? 'hide' : 'hidden';
    	var VISIBLE = (navi) ? 'show' : 'visible';
    	var cache = (navi) ? document.cache : document.all.cache.style;
    	largeur = screen.width;
    	cache.left = Math.round(100);
    	cache.visibility = VISIBLE;
    	}
    function cacheOff()
    	{
    	if (ver >= 4)
    		{
    		cache.visibility = HIDDEN;
    		}
    	}
    </SCRIPT>
<form name="form1">
  <select name="cats" onChange="jumptolink(document.form1.cats)">
    <option value="" selected>---Select Your Stone---</option>
    <%
While (NOT rsCats.EOF)
%>
    <option value="cat.asp?catalogID=<%=(rsCats.Fields.Item("catalogId").Value)%>"><%=(rsCats.Fields.Item("catalogName").Value)%></option>
    <%
  rsCats.MoveNext()
Wend
If (rsCats.CursorType > 0) Then
  rsCats.MoveFirst
Else
  rsCats.Requery
End If
%>
  </select><br><br>
  <a href="cart/cart.asp">View Current Order</a> 
</form>
<form name="NC_form">
<% If Not rsProds.EOF Or Not rsProds.BOF Then %>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td colspan="6"> <table width="100%" border="0" cellspacing="3" cellpadding="3">
          <tr> 
            <td width="33%" rowspan="5" valign="top"> <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><%=(rsInfo.Fields.Item("catalogName").Value)%></strong></font></p>
              <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><img src="<%=(rsInfo.Fields.Item("cat_pic").Value)%>" alt="" width="125" hspace="3"></strong></font></p></td>
            <td width="13%"><font color="#990000" size="2" face="Verdana, Arial, Helvetica, sans-serif">Texture</font></td>
            <td width="54%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
              <% if rsInfo("texture") <> "" then %>
              <%=(rsInfo.Fields.Item("texture").Value)%> 
              <% else %>
              No Data... 
              <% end if %>
              </font></td>
          </tr>
          <tr> 
            <td><font color="#990000" size="2" face="Verdana, Arial, Helvetica, sans-serif">Size</font></td>
            <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
              <% if rsInfo("SIZE") <> "" then %>
              <%=(rsInfo.Fields.Item("SIZE").Value)%> 
              <% else %>
              No Data... 
              <% end if %>
              </font></td>
          </tr>
          <tr> 
            <td><font color="#990000" size="2" face="Verdana, Arial, Helvetica, sans-serif">Coverage</font></td>
            <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
              <% if rsInfo("COVERAGE") <> "" then %>
              <%=(rsInfo.Fields.Item("COVERAGE").Value)%> 
              <% else %>
              No Data... 
              <% end if %>
              </font></td>
          </tr>
          <tr> 
            <td><font color="#990000" size="2" face="Verdana, Arial, Helvetica, sans-serif">Extra 
              Info</font></td>
            <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
              <% if rsInfo("coverage2") <> "" then %>
              <%=(rsInfo.Fields.Item("coverage2").Value)%> 
              <% else %>
              No Data... 
              <% end if %>
              </font></td>
          </tr>
        </table>
        <br> <table border="0" width="50%">
          <tr> 
            <td width="23%"> <font size="2"> 
              <% If MM_offset <> 0 Then %>
              <a href="<%=MM_moveFirst%>">First</a> 
              <% End If ' end MM_offset <> 0 %>
              </font></td>
            <td width="31%"> <font size="2"> 
              <% If MM_offset <> 0 Then %>
              <a href="<%=MM_movePrev%>">Previous</a> 
              <% End If ' end MM_offset <> 0 %>
              </font></td>
            <td width="23%"> <font size="2"> 
              <% If Not MM_atTotal Then %>
              <a href="<%=MM_moveNext%>">Next</a> 
              <% End If ' end Not MM_atTotal %>
              </font></td>
            <td width="23%"> <font size="2"> 
              <% If Not MM_atTotal Then %>
              <a href="<%=MM_moveLast%>">Last</a> 
              <% End If ' end Not MM_atTotal %>
              </font></td>
          </tr>
        </table>
        <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Showing <strong><%=(rsProds_first)%></strong> to <strong><%=(rsProds_last)%></strong> of <strong><font color="#990000"><%=(rsProds_total)%></font></strong> total items in <strong><%=(rsInfo.Fields.Item("catalogName").Value)%></strong></font><br> <br> </td>
    </tr>
    <tr> 
      <td width="12%" bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">CS 
        Code</font></td>
      <td width="23%" bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Name</font></td>
      <td width="38%" bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Description</font></td>
      <td width="15%" align="center" bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Stock</font></td>
      <td width="12%" align="right" bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Add 
        </font></td>
    </tr>
    <tr> 
      <td colspan="6">&nbsp;</td>
    </tr>
    <% 
While ((Repeat1__numRows <> 0) AND (NOT rsProds.EOF)) 
%>
    <tr> 
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="javascript:void(0)" onClick="GP_AdvOpenWindow('detail.asp?productID=<%=(rsProds.Fields.Item("productID").Value)%>','Detail','fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no',650,350,'center','ignoreLink','',0,'');return document.MM_returnValue"><%=(rsProds.Fields.Item("productcode").Value)%></a></font></td>
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(rsProds.Fields.Item("productName").Value)%></font></td>
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(rsProds.Fields.Item("productDesc").Value)%></font></td>
      <td width="15%" align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(rsProds.Fields.Item("numinstock").Value)%></font></td>
      <td width="12%" align="right"><font color="#990000" size="1" face="Verdana, Arial, Helvetica, sans-serif">Qty:</font> 
        <input name="<%=(rsProds.Fields.Item("productCode").Value)%>" type=text value="" size=2> 
        <input type="hidden" name="<%=(rsProds.Fields.Item("productCode").Value)%>_price" value="<%=(rsProds.Fields.Item("productWt").Value)%>"> 
        <input type="hidden" name="<%=(rsProds.Fields.Item("productCode").Value)%>_desc"  value="<%=(rsProds.Fields.Item("productName").Value)%>-<%=(rsProds.Fields.Item("productDesc").Value)%>"></td>
    </tr>
    <tr> 
      <td colspan="6"><hr size="1" noshade></td>
    </tr>
    <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsProds.MoveNext()
Wend
%>
    <tr> 
      <td colspan="6" align="right"><input type="button" onclick="AddItems()" value="Add 2 PO"> 
        &nbsp;&nbsp; <input name="Reset" type="reset" value="Reset"></td>
    </tr>
  </table>
<br>
  <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Showing <strong><%=(rsProds_first)%></strong> to <strong><%=(rsProds_last)%></strong> of <strong><font color="#990000"><%=(rsProds_total)%></font></strong> </font><br>
  <table border="0" width="37%">
    <tr> 
      <td width="23%"> <font size="2"> 
        <% If MM_offset <> 0 Then %>
        <a href="<%=MM_moveFirst%>">First</a> 
        <% End If ' end MM_offset <> 0 %>
        </font></td>
      <td width="31%"> <font size="2"> 
        <% If MM_offset <> 0 Then %>
        <a href="<%=MM_movePrev%>">Previous</a> 
        <% End If ' end MM_offset <> 0 %>
        </font></td>
      <td width="23%"> <font size="2"> 
        <% If Not MM_atTotal Then %>
        <a href="<%=MM_moveNext%>">Next</a> 
        <% End If ' end Not MM_atTotal %>
        </font></td>
      <td width="23%"> <font size="2"> 
        <% If Not MM_atTotal Then %>
        <a href="<%=MM_moveLast%>">Last</a> 
        <% End If ' end Not MM_atTotal %>
        </font></td>
    </tr>
  </table>
<% End If ' end Not rsProds.EOF Or NOT rsProds.BOF %>
</form>
<p></p>
<% If rsProds.EOF And rsProds.BOF Then %>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">No Products Found...</font></p>
<% End If ' end rsProds.EOF And rsProds.BOF %>
</body>
</html>
<%
rsCats.Close()
Set rsCats = Nothing
%>
<%
rsProds.Close()
Set rsProds = Nothing
%>
<%
rsInfo.Close()
Set rsInfo = Nothing
%>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 01-24-07, 09:48 AM
koncept
Guest
 
Posts: n/a
im just gonna post this page
http://www.asp101.com/samples/viewas..._selection.asp

it is what you want, i understand the code but it is well comented so im not going to comment. it should let you solve this really quick. again you will need that where in (mylist) in your sql statement or you cna do or col = 1 or col = 2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 01-24-07, 10:35 AM
elessar elessar is offline
Newbie Coder
 
Join Date: Jan 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for that page koncept but that is for a static example although it does shed some light on the problem. that code only displays what you have chosen(kind of what i need) but my problem is how do i take that list and pull out information from a db for display?

In my example I have a list of categories and if i choose 3 categories in that select box, how do i get all the products that belong to those 3 (selected) categories ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 01-24-07, 05:00 PM
koncept
Guest
 
Posts: n/a
that is the sql that is needed. at the top of the page (your form action one) you put
response.write(request.form("name"))
response.end()

does it show the correct list of items? if so then all you need to do is modify your sql select.

correct me if im wrong, you used macromedia dreamweaver to create the db code?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 01-26-07, 10:47 PM
elessar elessar is offline
Newbie Coder
 
Join Date: Jan 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
i was using DW for the code base but ive hand written it now.

I have this page as the search page:
Code:
<%@ Language=VBScript %>
<% pageTitle = "Search Page" %>
<!-- #include file="db.asp" -->
<!-- #include file="adovbs.inc" -->
<%
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConString

set rsCatalog = Conn.Execute("select * from vanprods")
%>

<html>
<head>
<meta name="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title><%= pageTitle %></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="total.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="70%" border="0" cellpadding="4" cellspacing="4">
  <tr> 
    <td class="total"> Search our Catagories 
      <form action="searchAction.asp" method="post">
        <select name="strCat" multiple size="10">
          <%
            rsCatalog.MoveFirst
            while not rsCatalog.EOF
        %>
          <option value="<%= rsCatalog("CatalogID") %>">
          <%Response.Write rsCatalog("catalogName")%>
          <%
            rsCatalog.MoveNext
            wend
        %>
        </select>
        <p> 
          <input type="submit" value="Submit Query">
      </form>
      <%
rsCatalog.Close
set rsCatalog = Nothing

Conn.Close
set Conn = Nothing
%>
    </td>
  </tr>
</table>
</body>
</html>
Simple:

Here is my results page:
Code:
<%@ Language=VBScript %>
<% pageTitle = "Search Action" %>
<!--#include file="adovbs.inc"-->
<!--#include file="db.asp"-->
<%

cats = Request("strCats")
cats = Replace( cats, ", ", "','" )

set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConString

sqlText = "SELECT * FROM products WHERE catalodID IN ('" & cats & "')"
	 
%>
<link href="total.css" rel="stylesheet" type="text/css">        
</head>

<body>
<p class="total">Your search results:</p>
<table width="70%" border="0" cellspacing="3" cellpadding="3">
  <tr bgcolor="#CCCCCC"> 
    <td width="15%" class="total">Product Code</td>
	<td width="35%" class="total">Product Name</td>
    <td width="35%" class="total">Product Packaging</td>
    <td width="15%" class="total">Av Inventory</td>
  </tr>
</table>

<%
set rsProd = Conn.Execute(sqlText)
		
	If rsProd.BOF And rsProd.EOF Then
		Response.Write "<font face='Verdana' size='1'><strong>"
		Response.Write "No items found, please narrow your <a href='javascript:history.back()'>search.</a></b>"
	end if
    
while not rsProd.EOF
%>
<table width="70%" border="0" cellpadding="3" cellspacing="3">
  <tr> 
    <td width="15%" class="total"><a href="product.asp?intProdID=<% Response.Write rsProd("productID") %>"><%= rsProd("productCode") %></a></td>
    <td width="35%" class="total"><%= rsProd("productDesc") %></td>
	<td width="35%" class="total"><%= rsProd("productPack") %></td>
    <td width="15%" class="total"><%= rsProd("NumInStock") %></td>
   </tr>
</table>
<%        
rsProd.MoveNext
wend    
rsProd.Close
set rsProd = Nothing
    
Conn.Close
set Conn = Nothing
%>
</body>
</html>
And here is the error I get when doing the search:
Code:
Technical Information (for support personnel)

Error Type:
Microsoft JET Database Engine (0x80040E10)
No value given for one or more required parameters.
/shop/searchAction.asp, line 31


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 2.0.50215) 

Page:
POST 28 bytes to /shop/searchAction.asp

POST Data:
strCat=7&strCat=10&strCat=12
I don't get where the error is. Please help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple select box with PHP zoliky PHP 4 11-02-06 04:26 AM
code problem throws error matt001 ASP.NET 0 10-23-05 04:30 AM
Multiple column select box Dr-Leech HTML/XHTML/XML 1 08-31-04 12:27 AM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM


All times are GMT -5. The time now is 07:32 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.