Forums
This topic is locked
MULTIPLE CHECKBOX SELECTION
16 May 2007 15:33:31 0 0 posted:
I have search page with form that contains check box group. Results are displayed on separate results page.
Check box group works fine if none or only one check box is selected.
The problem is that when I select two or more check boxes results page shows no results (no error page just zero records showing) when there should be records displayed.
Can anybody please advise me how to get records displayed when two or more checkboxes are selected simultaneously?
I’m new to database driven website so I’m struggling with sql and Dreamweaver’s 8.0.2 advanced recordset (I’m using LIKE statement in sql, quotes are not used in 8.0.2 version).
I’m using: Dreamweaver 8.0.2, ASP VBScript, Access 2003 (one tabe named “mm_property” contains column named “p_use” with values “Kupujem”, “Prodajem”, “Za Najam”.
My form:
<pre id=code><font face=courier size=2 id=code><form action="results.asp" method="post" name="search1" id="search1">
<input name="use" type="checkbox" id="use" value="Prodajem" />
<input name="use" type="checkbox" id="use" value="Kupujem" />
<input name="use" type="checkbox" id="use" value="Za Najam" />
<input type="submit" name="Submit" value="Submit" /></font id=code></pre id=code>
Recordset code on results page:
<pre id=code><font face=courier size=2 id=code><%
Dim rsResults__use
rsResults__use = "%"
If (Request.Form("use" <> "" Then
rsResults__use = Request.Form("use"
End If
%>
rsResults_cmd.CommandText = "SELECT * FROM mm_property WHERE p_use LIKE use"</font id=code></pre id=code>
Please help!
Replies
Replied 26 May 2007 15:11:16
26 May 2007 15:11:16 0 0 replied:
If there is anybody with asp skills and knows sql regarding checkboxes or listboxes can you drop me a hint regarding LIKE statement please.
I'm stuck, please help!
I'm stuck, please help!
Replied 01 Jun 2007 23:48:39
01 Jun 2007 23:48:39 Kenneth Halley replied:
If I am understanding your problem Mirela I think it might be that you have three checkboxes all using the same id/name i.e "use".
Try naming them differently for exampl chk1, chk2 and chk3
Now in your SQL you can each variable as appropriate using AND or OR criteria (depending what your trying to achieve- obviously i don't know the logic of your page but as an example
SELECT * FROM mm_property WHERE p_use LIKE chk1 OR p_use Like chk2 OR p_use chk3
You won't be able to use AND as this would logically negate most searches onthe same field- ie if chk1=1 and chk2 =2 and you want to search on the p_use filed and it can only have one value per record- your SQL would return an empty recordset as it can't be both 1 AND 2
Hope this help sif I understand. Can't help with ASP as I don't write this myself.
Kenny
-----------------------------------
www.halleynet.co.uk
Try naming them differently for exampl chk1, chk2 and chk3
Now in your SQL you can each variable as appropriate using AND or OR criteria (depending what your trying to achieve- obviously i don't know the logic of your page but as an example
SELECT * FROM mm_property WHERE p_use LIKE chk1 OR p_use Like chk2 OR p_use chk3
You won't be able to use AND as this would logically negate most searches onthe same field- ie if chk1=1 and chk2 =2 and you want to search on the p_use filed and it can only have one value per record- your SQL would return an empty recordset as it can't be both 1 AND 2
Hope this help sif I understand. Can't help with ASP as I don't write this myself.
Kenny
-----------------------------------
www.halleynet.co.uk
Replied 02 Jun 2007 12:59:18
02 Jun 2007 12:59:18 0 0 replied:
Kenneth,
Just to say thank you for your reply. I'll try your suggestion and see if I can get it to work.
Once again I appreciate you finding the time to reply to my post.
Will let you know how I'm getting on.
Just to say thank you for your reply. I'll try your suggestion and see if I can get it to work.
Once again I appreciate you finding the time to reply to my post.
Will let you know how I'm getting on.