1 Replies - 1831 Views - Last Post: 02 May 2011 - 07:36 AM Rate Topic: -----

#1 Raywin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-April 11

[question] dynamic multiple checkbox and get result with database

Posted 30 April 2011 - 07:40 AM

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.

<--- 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>


<--- 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>



Is This A Good Question/Topic? 0
  • +

Replies To: [question] dynamic multiple checkbox and get result with database

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • Joined: 13-January 08

Re: [question] dynamic multiple checkbox and get result with database

Posted 02 May 2011 - 07:36 AM

The number of checkboxes you're seeing from line 4 (within the cfoutput loop starting on line 3) will be determined by the number of records your Features query came back with.

Further, your line 4 should close the "break" tag so it'd look like this:

 <input type="checkbox" name="FeatureID" value="#FeatureID#">#Feature# <br>  

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1