Dynamic Multiple Checkbox And Get Result With Database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Raywin
    New Member
    • Apr 2011
    • 1

    Dynamic Multiple Checkbox And Get Result With Database

    Hello everyone, i am facing a problem with multiple checkbox.
    I have set few checkbox as a selection, then send to database for search result.
    For example the checkbox including hotel features like, aircont, 24 hour reception, swiming pool etc.
    after tick the check box , will send to result page to get the Hotel match with the selection checkbox.

    But my level only can make just one selection and get the result, if choose more than 1 selection will get error.

    Code:
    <--- HTML Page --->
    <cfform action="test_action.cfm">
        <cfoutput query="Features">
        <input type="checkbox" name="FeatureID" value="#FeatureID#">#Feature# <br                                 </cfoutput>
         <input type="submit" value="Search">
    </cfform>
    Code:
    <--- Query Page --->
    <cfparam name="FORM.HotelID" default="">
    
    <cfquery name="Hotel" datasource="#ds#">
    SELECT Hotel_ID, Name
    FROM Hotel
    WHERE 0=0
    <cfif FORM.HotelID IS NOT "">
     AND HotelID = #FORM.HotelID#
    
    <cfoutput query="Hotel">
    	<tr>
    		<td>#HotelID#</td>
    		<td>#Name#</td>
    	</tr>
    </cfoutput>
    </cfif>
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    That's because HotelID will be a list. You could use the IN keyword with () to search all selected hotels, e.g.
    Code:
    AND HotelID in (#FORM.HotelID#)
    Your code will result in an error unless you've not posted the full code on the page.

    Comment

    Working...