Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Use checkboxes to filter recordset on next page

Posted 15 Jun 2002 18:43:14
1
has voted
15 Jun 2002 18:43:14 Lesley Gregg posted:
UltraDev4, ASP, VBscript, MySQL

I have a form (get action) which contains multiple checkboxes, with a submit button that sucessfully sends the record IDs of the checked boxes to the next page.

Challenge: How to use these IDs to filter a recordset?

I just want to display the records that were selected via the checkboxes, as a recordset.

I know how to get the data to display just as a string of data but this needs to be converted in some way into a recordset so that other associated info can be drawn from the database.

Have seen plenty of tutorials about how to code this info to delete records, but that isn't my aim.
Anyone help me please?

Replies

Replied 16 Jun 2002 04:15:45
16 Jun 2002 04:15:45 Owen Eastwick replied:
If all your checkboxes have the same name, like this:

<input type="checkbox" name="checkbox" value="1">
<input type="checkbox" name="checkbox" value="2">
<input type="checkbox" name="checkbox" value="3">
etc...

On the page to which the form sends the results collect the values from the URL parameter:

<% varString = Request.QueryString("checkbox" %>

Which would give you a string like this:

1, 2, 3

Now set up your recordset and modify the select statement like this:

RecordsetName.Source = "SELECT Whatever, WhateverElse, AndTheRest FROM TableName WHERE IDFieldName IN (" & varString & ""

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo

Edited by - oeastwick on 16 Jun 2002 04:16:55
Replied 16 Jun 2002 16:26:17
16 Jun 2002 16:26:17 Lesley Gregg replied:
Hi Oeastwick,

Thank you for reply. Unfortunately this didn't work - maybe I'm doing something wrong? Code as below:

<%= varString = Request.QueryString("mailbox"%>
<%
set notify = Server.CreateObject("ADODB.Recordset"
notify.ActiveConnection = MM_phdsweb_STRING
notify.Source = "SELECT id, firstname, surname, town, county, email FROM creatives WHERE id IN (" & varString & "" etc

The above returned an error message:

False
Microsoft OLE DB Provider for ODBC Drivers error '80040e09'

[TCX][MyODBC]You have an error in your SQL syntax near ')' at line 1

/genericlocal/webcreatives/wcnadmin/mailer.asp, line 11


I'm wondering if the reason this won't work is something to do with the MySQL server, as opposed to SQL server?

If you spot an error with the above, I'd be grateful if you could let me know,
Cheers,
Lesley

Edited by - Lesley G on 16 Jun 2002 16:28:59
Replied 16 Jun 2002 20:09:29
16 Jun 2002 20:09:29 Owen Eastwick replied:
You've got an extra equals sign in this line:

<%= varString = Request.QueryString("mailbox"%>

Modify it like this:

<% varString = Request.QueryString("mailbox" %>

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 17 Jun 2002 11:10:48
17 Jun 2002 11:10:48 Lesley Gregg replied:
A massive thank you Owen for your help. Works great.

Lesley G

Reply to this topic