|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Checkboxes not passing variables correctly
I have a group of 10 checkboxes where 3 have to be checked. I have a JSSteve LaBadie 03/25/08 08:12 A Steve,Cutter (CFRelated) 03/25/08 08:40 A This is the script to check for 3 checked boxes:Steve LaBadie 03/25/08 08:46 A No, there's nothing there that would explain it. I'd like to blame it onCutter (CFRelated) 03/25/08 09:43 A This script work correctly, try it.Davide Campo 03/25/08 09:49 A >>delimiters="crlf">Claude Schneegans 03/25/08 09:58 A Is there a list of all possible delimiters value?Steve LaBadie 03/25/08 10:16 A >>Is there a list of all possible delimiters value?Claude Schneegans 03/25/08 10:26 A What is your desired output?Matt Williams 03/25/08 10:27 A If you just want the list of names, separated by comma and space, then use:morgan l 03/25/08 10:27 A >>Is there a list of all possible delimiters value?Claude Schneegans 03/25/08 10:28 A Thanks everyone for your input and wisdom. Thanks Claude for the laugh.Steve LaBadie 03/25/08 10:34 A Faculty Supervisor: <cfloop list="#form.fac#" index="f"Azadi Saryev 03/25/08 09:50 A the value attrubute of your checkboxes are different from theirAzadi Saryev 03/25/08 01:11 P > Is there a list of all possible delimiters value?Dominic Watson 03/25/08 03:53 P Thank you Dominic for the extra input, very helpful examples.Steve LaBadie 03/25/08 03:57 P 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> 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 ----- 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 ----- 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 ----- 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> >>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. 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. >>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. 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 ----- 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 ----- >>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. 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. 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 ----- 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 ----- > 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 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
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||