Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 3rd, 2008, 07:57 AM
rcollins207's Avatar
Newbie
 
Join Date: Sep 2008
Posts: 4
Default tracking the number of checkboxes selected

what i have to do is make sure that they only select a certain amount of items i have looked everywhere but it must be a simple thing that i cannot think of please any help would be great!! so i think that all i need to do is track the number that is selected when they click submit but i cannot find the answer please help me.


[CODE=cfm] <cfinput type="checkbox" name="fill2" value="1" id="fill2">
Chicken &amp; Salad<br>
<cfinput type="checkbox" name="fill2" value="2" id="fill2">
Egg &amp; lettuce<br>
<cfinput type="checkbox" name="fill2" value="3" id="fill2">
Mediterranean<br>
<cfinput type="checkbox" name="fill2" value="4" id="fill2">
Chicken Caesar<br>
<cfinput type="checkbox" name="fill2" value="5" id="fill2">
Smoked Salmon &amp; Brie Cheese<br>
<cfinput type="checkbox" name="fill2" value="6" id="fill2">
Ham &amp; Salad<br>
<cfinput type="checkbox" name="fill2" value="7" id="fill2">
Vegetarian<br>
<cfinput type="checkbox" name="fill2" value="8" id="fill2">
Roast Beef</p>
</div>[/code]

Last edited by acoder; September 3rd, 2008 at 11:58 AM. Reason: Added [code] tags
Reply
  #2  
Old September 3rd, 2008, 12:03 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 12,593
Default

The fill2 variable will be a list containing the values of the checked checkboxes. It could be undefined if none are checked, so you should use cfparam to default to the empty string.
Reply
  #3  
Old September 4th, 2008, 12:05 AM
rcollins207's Avatar
Newbie
 
Join Date: Sep 2008
Posts: 4
Default

thank you for the reply....
i haven't used <cfparam> yet and i will look into it now thank you but what i need to now is how do i make it that they have to select 4 no more no less how do i track how many that they have selected.
what they want is three radio buttons that determines how many fills they want (4,5,6)
and under that i have 8 checkboxes that are the fills but how many that they aloud to be selected depends on the three radiobuttuons
thanks for the help
Reply
  #4  
Old September 4th, 2008, 11:15 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 12,593
Default

As I said, it'll be a list, so use listlen on the form variable. Assuming you sent it as a post request, it would be form.fill2:
[code=cfm]<cfif listlen(form.fill2) EQ 4>[/code]
Reply
  #5  
Old September 5th, 2008, 12:09 AM
rcollins207's Avatar
Newbie
 
Join Date: Sep 2008
Posts: 4
Default

thanks mate that worked :) well
Reply
  #6  
Old September 5th, 2008, 11:31 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 12,593
Default

You're welcome :) Glad it worked.
Reply
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles