House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

isDefined inside a cfloop

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
you should be able to use
Greg Morphis
04/30/12 10:52 A
Greg, Dave,
Steve LaBadie
04/30/12 11:01 A
Can you show us the HTML you are using?
Raymond Camden
04/30/12 11:12 A
<label for="Veteran">Veteran:</label>
Steve LaBadie
04/30/12 11:25 A
> <label for="Veteran">Veteran:</label>
Dave Watts
04/30/12 11:28 A
Greg,
Steve LaBadie
04/30/12 01:01 P
As long as you have some separation..
Greg Morphis
04/30/12 01:17 P
> As long as you have some separation..
Christopher Watson
04/30/12 01:32 P
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve LaBadie
04/30/2012 10:44 AM

I have a form with the results being emailed to the owner of the form. I have several groups of radio buttons and checkboxes. I am using the following to check for the empty form control: Veteran: <cfloop from="1" to="10" index="v"><cfif isDefined("FORM.Veteran#v#")><cfoutput>#v#</cfoutput></cfif></cfloop> This does work for checking if it is empty but does not return a result if it is answered. FYI - I am still using MX7 and am in the process of upgrading to CF9, but need to get this to work for now. Steve LaBadie, Web Manager East Stroudsburg University 570-422-3999 http://www.esu.edu <http://www.esu.edu/>; slabadie@esu.edu

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
04/30/2012 10:50 AM

----- Excess quoted text cut - see Original Post for more ----- Wouldn't you also want to output "FORM.Veteran#v#"? Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Greg Morphis
04/30/2012 10:52 AM

you should be able to use form["veteran#v#"] to get the value On Mon, Apr 30, 2012 at 9:44 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:
Steve LaBadie
04/30/2012 11:01 AM

Greg, Dave, No luck. Steve LaBadie, Web Manager East Stroudsburg University 570-422-3999 http://www.esu.edu slabadie@esu.edu you should be able to use form["veteran#v#"] to get the value On Mon, Apr 30, 2012 at 9:44 AM, Steve LaBadie <slabadie@po-box.esu.edu>wrote: > > I have a form with the results being emailed to the owner of the form. I ----- Excess quoted text cut - see Original Post for more ----- result ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
04/30/2012 11:12 AM

Can you show us the HTML you are using? Have you tried cfdumping the form scope to see what is there? ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve LaBadie
04/30/2012 11:25 AM

<label for="Veteran">Veteran:</label> <select name="Veteran" id="Veteran"> <option>Select...</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> Steve LaBadie, Web Manager East Stroudsburg University 570-422-3999 http://www.esu.edu slabadie@esu.edu

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
04/30/2012 11:28 AM

> <label for="Veteran">Veteran:</label> ----- Excess quoted text cut - see Original Post for more ----- Well that doesn't match what you're looking for in your form processing code at all. First, this will always have a value in your action page, and second, the name of the field will simply be form.veteran, not form.veteran plus some number. Also, you might want to use radio buttons for Boolean questions instead of select boxes. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve LaBadie
04/30/2012 11:31 AM

I am using radio buttons as well on the form and I get the same empty results <label class="field-label-nostyle" for="UnderGrad"><strong>Do you have an Undergraduate Degree?</strong></label> <label class="field-label-nostyle" style="margin-left: 10px !important">Yes <input type="radio" id="UnderGrad" name="UnderGrad" value="Yes" /></label> <label class="field-label-nostyle" style="margin-left: 10px !important">No <input type="radio" name="UnderGrad" value="No" /></label> Steve LaBadie, Web Manager East Stroudsburg University 570-422-3999 http://www.esu.edu slabadie@esu.edu ----- Excess quoted text cut - see Original Post for more ----- Well that doesn't match what you're looking for in your form processing code at all. First, this will always have a value in your action page, and second, the name of the field will simply be form.veteran, not form.veteran plus some number. Also, you might want to use radio buttons for Boolean questions instead of select boxes. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Greg Morphis
04/30/2012 12:13 PM

Why not use <cfparams> on the action page and default the values? You can even default their value to "" and then if it equals that inform the user they need to go back and choose one. Or in your form on either the Yes or No, use checked="checked" to default one or the other to being checked. On Mon, Apr 30, 2012 at 10:31 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:
Russ Michaels
04/30/2012 12:21 PM

fr4om your examples you are naming both your select list and your check boxes with the same name " Veteran", which would cause you a problem, you need to make sure they have unique names. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve LaBadie
04/30/2012 01:01 PM

Greg, Does it matter that form and the action page are on and the same? Steve LaBadie, Web Manager East Stroudsburg University 570-422-3999 http://www.esu.edu slabadie@esu.edu Why not use <cfparams> on the action page and default the values? You can even default their value to "" and then if it equals that inform the user they need to go back and choose one. Or in your form on either the Yes or No, use checked="checked" to default one or the other to being checked. On Mon, Apr 30, 2012 at 10:31 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:
Greg Morphis
04/30/2012 01:17 PM

As long as you have some separation.. something like: <cfparam name="form.process" default="0" /> <cfif isdefined(form.process) and form.process eq 1> <cfparam name="form.foo" default="" /> ... <cfif form.foo eq ""> Nothing was entered! </cfif> ... <!--- process form ---> <cfelse> <!--- display form ---> <form> <input type="hidden" name="process" value="1" /> ... </cfif> Something like that.. but I always separate my form from the action page, makes the code less cluttered. On Mon, Apr 30, 2012 at 12:01 PM, 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:
Christopher Watson
04/30/2012 01:32 PM

> As long as you have some separation.. > [code examples snipped] One of the strengths of ColdFusion (and, indeed, other languages of its ilk) is that you don't have to separate your input interfaces from your back-end processing, and even the response display. There are sound reasons for implementing direct feedback form input interfaces within a single template, conditionalizing the function points. In some cases, good UI and app design dictate that it all be rolled into one, because the input, processing, and response may all be visually integrated (i.e., what you enter into the form and submit comes back at you in a processed form, providing necessary results feedback). If your input UI is the basis for a self-same response display, then it makes perfect sense to roll it all into one template, allowing one to maintain that code in a single place. But of course, YMMV. I just wanted to make note that there's nothing inherently bad about designing things that way. -Christopher

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Russ Michaels
04/30/2012 01:39 PM

allthough most here would aregue that your business logic should at least be in a separate CFC so that the code is re-usable. There are some good form handlers out there that do all the validation and generate nice error messages for you. here is one off the top of my head http://pengoworks.com/index.cfm?action=get:qforms On Mon, Apr 30, 2012 at 6:32 PM, Christopher Watson <skygeex@gmail.com>wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve LaBadie
04/30/2012 02:02 PM

I am not ignoring any of you; Thank you all for your input. I am just trying different things without any luck. Steve LaBadie, Web Manager East Stroudsburg University 570-422-3999 http://www.esu.edu slabadie@esu.edu allthough most here would aregue that your business logic should at least be in a separate CFC so that the code is re-usable. There are some good form handlers out there that do all the validation and generate nice error messages for you. here is one off the top of my head http://pengoworks.com/index.cfm?action=get:qforms On Mon, Apr 30, 2012 at 6:32 PM, Christopher Watson <skygeex@gmail.com>wrote: > > > As long as you have some separation.. > > [code examples snipped] > > One of the strengths of ColdFusion (and, indeed, other languages of its > ilk) is that you don't have to separate your input interfaces from your > back-end processing, and even the response display. There are sound reasons > for implementing direct feedback form input interfaces within a single > template, conditionalizing the function points. In some cases, good UI and > app design dictate that it all be rolled into one, because the input, > processing, and response may all be visually integrated (i.e., what you > enter into the form and submit comes back at you in a processed form, > providing necessary results feedback). If your input UI is the basis for a > self-same response display, then it makes perfect sense to roll it all into > one template, allowing one to maintain that code in a single place. But of > course, YMMV. I just wanted to make note that there's nothing inherently > bad about designing things that way. > > -Christopher > >

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Christopher Watson
04/30/2012 02:06 PM

Absolutely. In 100% agreement there. Though the invocation of the CFC can still live in the multi-function form template. > allthough most here would aregue that your business logic > should at least be in a separate CFC so that the code is > re-usable.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Christopher Watson
04/30/2012 02:33 PM

Steve, to respond to your inquiry specifically, I've always felt it was best to take complete control over what is in the Form scope, right from the top, by laying out a series of <cfparam> tags and their default values, especially if check boxes or initially-unselected radio button groups are part of the form. <cfparam name="Form.thisField" default=""> <cfparam name="Form.thatField" default="0"> Then my back-end logic, working with the assumption that everything IS defined, regardless of what the user did or did not do in the form, is free to simply test a form field value to see if it has changed from its default to know if it has been selected or a user value provided. No dinking around with browser implementation junk. With that Yes/No radio button thing, general UI guidelines specify that at least one element of a mutually exclusive control group be defaulted to 'selected' when the interface is presented. After having said that, though, you should actually consider changing question input like "Do you have an Undergraduate Degree?" from a Yes/No (boolean) radio button input to simply a single check box, with a rephrased question like "I have an Undergraduate Degree". Then, that's where your use of the <cfparam> tag comes into play, because you can prescribe a fixed value to that one check box input element, and only when the check box is checked off does that become the value for it, differentiating it from the default value, and indicating that it was "selected". <cfparam name="Form.UnderGrad" default="0"> ... <input type="checkbox" name="UnderGrad" value="1"> <strong>I have an Undergraduate Degree</strong> ... <cfif Form.UnderGrad eq 1>     <!--- If it equals 1 at form submit, instead of the default 0, then it was selected ---> </cfif> -Christopher

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Steve LaBadie
04/30/2012 02:37 PM

Thanks Christopher, that is what I wound up doing. Steve LaBadie, Web Manager East Stroudsburg University 570-422-3999 http://www.esu.edu slabadie@esu.edu Steve, to respond to your inquiry specifically, I've always felt it was best to take complete control over what is in the Form scope, right from the top, by laying out a series of <cfparam> tags and their default values, especially if check boxes or initially-unselected radio button groups are part of the form. <cfparam name="Form.thisField" default=""> <cfparam name="Form.thatField" default="0"> Then my back-end logic, working with the assumption that everything IS defined, regardless of what the user did or did not do in the form, is free to simply test a form field value to see if it has changed from its default to know if it has been selected or a user value provided. No dinking around with browser implementation junk. With that Yes/No radio button thing, general UI guidelines specify that at least one element of a mutually exclusive control group be defaulted to 'selected' when the interface is presented. After having said that, though, you should actually consider changing question input like "Do you have an Undergraduate Degree?" from a Yes/No (boolean) radio button input to simply a single check box, with a rephrased question like "I have an Undergraduate Degree". Then, that's where your use of the <cfparam> tag comes into play, because you can prescribe a fixed value to that one check box input element, and only when the check box is checked off does that become the value for it, differentiating it from the default value, and indicating that it was "selected". <cfparam name="Form.UnderGrad" default="0"> ... <input type="checkbox" name="UnderGrad" value="1"> <strong>I have an Undergraduate Degree</strong> ... <cfif Form.UnderGrad eq 1>     <!--- If it equals 1 at form submit, instead of the default 0, then it was selected ---> </cfif> -Christopher


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

Search cf-talk

May 25, 2013

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

Designer, Developer and mobile workflow conference