House of Fusion
Home of the ColdFusion Community

Search cf-talk

December 02, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31       

Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

Checkboxes not passing variables correctly

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve LaBadie
03/25/2008 08:12 AM

I have a group of 10 checkboxes where 3 have to be checked. I have a JS script to validate this. The issue at hand is the values are not being passed completely. If you choose Robert Mckenzie the name is passed Robet Mkenzie, any ideas would be appreciated. Steve LaBadie, Web Manager East Stroudsburg University 200 Prospect St. East Stroudsburg, Pa 18301 570-422-3999 slabadie@po-box.esu.edu <mailto:slabadie@po-box.esu.edu> http://www.esu.edu <http://www.esu.edu>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Cutter (CFRelated)
03/25/2008 08:40 AM

Steve, We want to help, but without seeing the form code it is almost impossible to troubleshoot. Steve "Cutter" Blades Adobe Certified Professional Advanced Macromedia ColdFusion MX 7 Developer _____________________________ http://blog.cutterscrossing.com Steve LaBadie wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve LaBadie
03/25/2008 08:46 AM

This is the script to check for 3 checked boxes: <script> function is_checked() { var formObj = document['internships']['fac']; var count = 0; for (i=0;i<formObj.length; i++) { if(formObj[i].type == 'checkbox') if(formObj[i].checked) count++; } if (count < 3) { return false; }else { return true; } } function val(){ if (!is_checked()){ alert('You Must Choose 3 Faculty Supervisors'); return false; }else { return true; } } </script> <tr><td align="right" valign="top"><strong>Faculty Supvisor:</strong> <br /><font style="color: #BD2925; font-size: xx-small;">(Choose 3)</font> </td><td> <input type="checkbox" name="fac" value="Joseph Ashcroft" /> Joseph Ashcroft<br /> <input type="checkbox" name="fac" value="Paul Lippert" /> Paul Lippert<br /> <input type="checkbox" name="fac" value="Charles Warner" /> Charles Warner<br /> <input type="checkbox" name="fac" value="Marcia Godich" /> Marcia Godich<br /> <input type="checkbox" name="fac" value="Andrea McClanahan" /> Andrea McClanahan</td> <td><input type="checkbox" name="fac" value="Glenn Geiser-Getz" /> Glenn Geiser-Getz<br /> <input type="checkbox" name="fac" value="Robert McKenzie" /> Robert McKenzie<br /> <input type="checkbox" name="fac" value="Wenji Yan" /> Wenjie Yan<br /> <input type="checkbox" name="fac" value="Patricia Kennedy" /> Patricia Kennedy<br /> <input type="checkbox" name="fac" value="Cem Zeytinoglu" /> Cem Zeytinoglu </td></tr> Action page: Faculty Supervisor: <cfloop list="#form.fac#" index="f" delimiters="crlf">#f#</cfloop> Steve LaBadie, Web Manager East Stroudsburg University 200 Prospect St. East Stroudsburg, Pa 18301 570-422-3999 slabadie@po-box.esu.edu http://www.esu.edu -----Original Message----- Steve LaBadie wrote: > I have a group of 10 checkboxes where 3 have to be checked. I have a JS ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Cutter (CFRelated)
03/25/2008 09:43 AM

No, there's nothing there that would explain it. I'd like to blame it on the font tags, but I can't;) Steve "Cutter" Blades Adobe Certified Professional Advanced Macromedia ColdFusion MX 7 Developer _____________________________ http://blog.cutterscrossing.com Steve LaBadie wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Davide Campo
03/25/2008 09:49 AM

This script work correctly, try it. <cfif isDefined("Form.submit")> <cfloop list="#form.fac#" index="f" delimiters="crlf"><cfoutput>#f#</cfoutput></cfloop> </cfif> <form name="internships" action="" onsubmit="return val()" method="post"> <script>   function is_checked() {          var formObj = document['internships']['fac'];     var count = 0;     for (i=0;i<formObj.length; i++) {       if(formObj[i].type == 'checkbox') {         if(formObj[i].checked) count++;       }     }     if (count < 3) {       return false;     }else {       return true;     }   }   function val(){     if (!is_checked()){       alert('You Must Choose 3 Faculty Supervisors');       return false;     }else {       return true;     }   } </script> <tr><td align="right" valign="top"><strong>Faculty Supvisor:</strong> <br /><font style="color: #BD2925; font-size: xx-small;">(Choose 3)</font> </td><td> <br /> <input type="checkbox" name="fac" value="Joseph Ashcroft" /> Joseph Ashcroft<br /> <input type="checkbox" name="fac" value="Paul Lippert" /> Paul Lippert<br /> <input type="checkbox" name="fac" value="Charles Warner" /> Charles Warner<br /> <input type="checkbox" name="fac" value="Marcia Godich" /> Marcia Godich<br /> <input type="checkbox" name="fac" value="Andrea McClanahan" /> Andrea McClanahan<br> <input type="checkbox" name="fac" value="Glenn Geiser-Getz" /> Glenn Geiser-Getz<br /> <input type="checkbox" name="fac" value="Robert McKenzie" /> Robert McKenzie<br /> <input type="checkbox" name="fac" value="Wenji Yan" /> Wenjie Yan<br /> <input type="checkbox" name="fac" value="Patricia Kennedy" /> Patricia Kennedy<br /> <input type="checkbox" name="fac" value="Cem Zeytinoglu" /> Cem Zeytinoglu </td></tr> <input type="submit" value="submit" name="submit" /> </form>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Claude Schneegans
03/25/2008 09:58 AM

>>delimiters="crlf"> You're using "crlf" as delimitior? No wonder c, r, l & f are lost. You probably meant CR LF, but these are not the delimiters used to separate field values, the simple comma is used. So just use Faculty Supervisor: <cfloop list="#form.fac#" index="f">#f#</cfloop> or more simply: Faculty Supervisor: #form.fac# -- _______________________________________ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: piegeacon@internetique.com) Thanks.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve LaBadie
03/25/2008 10:16 AM

Is there a list of all possible delimiters value? If I use your suggestion there are no spaces or commas between full names when the information is sent. If I use delimiters="| " there is a comma but no space after comma. Steve LaBadie, Web Manager East Stroudsburg University 200 Prospect St. East Stroudsburg, Pa 18301 570-422-3999 slabadie@po-box.esu.edu http://www.esu.edu >>delimiters="crlf"> You're using "crlf" as delimitior? No wonder c, r, l & f are lost. You probably meant CR LF, but these are not the delimiters used to separate field values, the simple comma is used. So just use Faculty Supervisor: <cfloop list="#form.fac#" index="f">#f#</cfloop> or more simply: Faculty Supervisor: #form.fac# -- _______________________________________ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: piegeacon@internetique.com) Thanks.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Claude Schneegans
03/25/2008 10:26 AM

>>Is there a list of all possible delimiters value? There only one delimiter: the comma, which is the default delimiter for all list functions, so you don't need to specify one. -- _______________________________________ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: piegeacon@internetique.com) Thanks.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matt Williams
03/25/2008 10:27 AM

What is your desired output? If you just want a straight list with commas between the chosen names, then do as Claude said: Faculty Supervisor: #form.fac# If you need line breaks between the names, then do a loop as Claude said (with a <br/> added): <cfloop list="#form.fac#" index="f"> #f#<br/> </cfloop> On Tue, Mar 25, 2008 at 9:12 AM, Steve LaBadie <slabadie@po-box.esu.edu> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
morgan l
03/25/2008 10:27 AM

If you just want the list of names, separated by comma and space, then use: Faculty Supervisor: #Replace(form.fac,",",", ","all")# On Tue, Mar 25, 2008 at 9:12 AM, Steve LaBadie <slabadie@po-box.esu.edu> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Claude Schneegans
03/25/2008 10:28 AM

>>Is there a list of all possible delimiters value? If you want to know more about forms and how values are passed, use <CFDUMP var="#form#"> in your action template and you'll know everything a young lady should know before wedding ;-) -- _______________________________________ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: piegeacon@internetique.com) Thanks.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve LaBadie
03/25/2008 10:34 AM

Thanks everyone for your input and wisdom. Thanks Claude for the laugh. Steve LaBadie, Web Manager East Stroudsburg University 200 Prospect St. East Stroudsburg, Pa 18301 570-422-3999 slabadie@po-box.esu.edu http://www.esu.edu >>Is there a list of all possible delimiters value? If you want to know more about forms and how values are passed, use <CFDUMP var="#form#"> in your action template and you'll know everything a young lady should know before wedding ;-) -- _______________________________________ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: piegeacon@internetique.com) Thanks.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Azadi Saryev
03/25/2008 09:50 AM

Faculty Supervisor: <cfloop list="#form.fac#" index="f" > delimiters="crlf">#f#</cfloop> that's your problem - your list delimiters. Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ Steve LaBadie wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Azadi Saryev
03/25/2008 01:11 PM

the value attrubute of your checkboxes are different from their labels/text? typos? Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ Steve LaBadie wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dominic Watson
03/25/2008 03:53 PM

> Is there a list of all possible delimiters value? A delimeter could be any 'legal' character in a string. The delimeter you use is informed by the string you are given to break up into list items; using different delimiters will break up your 'list' in different ways. Here is some code to demonstrate, just copy and past into a blank template and run it; then look over the output and hopefully things will become clear for you (if they haven't already): <cfset myList = "foo|bar,sticky toffee pudding|init"> <cfoutput> <h1>Delimiter demo</h1> <p> The list: #myList#</p> <h2>Using default delimiter (comma)</h2> <ul> <cfloop list="#myList#" index="listItem">   <li>#listItem#</li> </cfloop> </ul> <h2>Using '|'</h2> <ul> <cfloop list="#myList#" index="listItem" delimiters="|">   <li>#listItem#</li> </cfloop> </ul> <h2>Using '|' or ','</h2> <ul> <cfloop list="#myList#" index="listItem" delimiters="|,">   <li>#listItem#</li> </cfloop> </ul> <h2>Using any vowel</h2> <ul> <cfloop list="#myList#" index="listItem" delimiters="aeiou">   <li>#listItem#</li> </cfloop> </ul> <h2>Using a character that isn't in the string (@)</h2> <ul> <cfloop list="#myList#" index="listItem" delimiters="@">   <li>#listItem#</li> </cfloop> </ul> </cfoutput> Also, if you want a delimiter of CR LF (used quite regularly to delimit whole lines of a csv that have a line break to indicate a new row) you can use the Chr function: delimiters="#Chr(13)##Chr(10)#" HTH Dominic -- Blog it up: http://fusion.dominicwatson.co.uk

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve LaBadie
03/25/2008 03:57 PM

Thank you Dominic for the extra input, very helpful examples. Steve LaBadie, Web Manager East Stroudsburg University 200 Prospect St. East Stroudsburg, Pa 18301 570-422-3999 slabadie@po-box.esu.edu http://www.esu.edu > Is there a list of all possible delimiters value? A delimeter could be any 'legal' character in a string. The delimeter you use is informed by the string you are given to break up into list items; using different delimiters will break up your 'list' in different ways. Here is some code to demonstrate, just copy and past into a blank template and run it; then look over the output and hopefully things will become clear for you (if they haven't already): <cfset myList = "foo|bar,sticky toffee pudding|init"> <cfoutput> <h1>Delimiter demo</h1> <p> The list: #myList#</p> <h2>Using default delimiter (comma)</h2> <ul> <cfloop list="#myList#" index="listItem">   <li>#listItem#</li> </cfloop> </ul> <h2>Using '|'</h2> <ul> <cfloop list="#myList#" index="listItem" delimiters="|">   <li>#listItem#</li> </cfloop> </ul> <h2>Using '|' or ','</h2> <ul> <cfloop list="#myList#" index="listItem" delimiters="|,">   <li>#listItem#</li> </cfloop> </ul> <h2>Using any vowel</h2> <ul> <cfloop list="#myList#" index="listItem" delimiters="aeiou">   <li>#listItem#</li> </cfloop> </ul> <h2>Using a character that isn't in the string (@)</h2> <ul> <cfloop list="#myList#" index="listItem" delimiters="@">   <li>#listItem#</li> </cfloop> </ul> </cfoutput> Also, if you want a delimiter of CR LF (used quite regularly to delimit whole lines of a csv that have a line break to indicate a new row) you can use the Chr function: delimiters="#Chr(13)##Chr(10)#" HTH Dominic -- Blog it up: http://fusion.dominicwatson.co.uk


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists