- see footer for list info -<
couldn't you just find out the name of the function and then write your own
version in your page after the MM one has been declared, thereby effectively
overwriting the original MM version?
On 7/13/06, Charlie Arehart <[EMAIL PROTECTED]> wrote:
>- see footer for list info -<
Here's a solution to making the CFSELECT work as you want, Andrew.
First, let me say that I know that many hate any of the CFFORM tags, but
I'll clarify that for some uses (like CFSELECT in particular), it's not
too
bad (dynamically generating select options, doing the JS validation).
That said, this issue you raise about using REQUIRED on a single SELECT is
indeed one that MM/Adobe seems to have thought about. According to the
CFMX
7 docs, you should be able to work-around this. I quote:
You can work around this issue: format forms by having an initial
option tag with value=" " (note the space character between the quotation
marks).
This was from:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/h
tml/wwhelp.htm?context=ColdFusion_Documentation&file=part_cfm.htm
I've tested it, though, and it's not doing what it would suggest it
should.
Here's an example:
<cfform>
<cfselect name="test" required="Yes">
<option value=" ">select an option
<option>1
<option>2
</cfselect>
<input type="Submit">
</cfform>
Note that as of CFMX, you no longer need to bother with a NAME or ACTION
for
CFFORM, and like a regular <FORM>, if you leave off the ACTION it posts to
itself. If you add SIZE="2" and submit it without selecting an item, you
get
the expected validation for not choosing something, so it's not that
there's
anything wrong with the code above.
It just doesn't seem that their proposed "workaround" really works. I
looked
at the code in /CFIDE/scripts/cfform.js, which holds the _CF_hasValue
function that is called for the validation, and it just doesn't honor this
"workaround":
else if (obj_type == "SELECT")
{
for (i=0; i < obj.length; i++)
{
if (obj.options[i].selected)
return true;
}
return false;
If you change it to this, though, it seems to do the trick:
else if (obj_type == "SELECT")
{
for (i=0; i < obj.length; i++)
{
if (obj.options[i].selected)
{
if (obj.options[i].value == " ")
return false;
else
return true;
}
}
return false;
}
The question, then, is whether you want to change this JS file that CFFORM
relies on (or even have the security access to do it). I could see it
negatively affecting code where someone intentionally left a VALUE as " "
and meant for that to be passed through. It would seem that a better
solution would be to add an attribute for CFSELECT that enables this
"workaround" behavior more intentionally.
I'll write a blog entry about this and also point to it in the livedocs.
Maybe Adobe can address it in the future. Could be a nice bone for BD to
add. :-)
/charlie
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steve Duddell
Sent: Thursday, July 13, 2006 9:00 AM
To: Coldfusion Development
Subject: RE: [CF-Dev] cfselect
>- see footer for list info -<
I have had the same problem (on 6.1 anyways), was so annoying because I
HAD
to use CFFORM (wasn't allowed to re-do it as a normal FORM), and HAD to
have
a first option the same as you (like "Select Whatever"). Having
REQUIRED="Yes" is completely useless in a CFSELECT if it is a single
SELECT
list (or a multiple SELECT with SIZE=1). I had to fix it by editing CF's
cfform.js that sits in the CFIDE/scripts directory (which you might not
want/be able to do) to do a simple check to see if the SELECT list to
check
was multiple or single ... if(obj.multiple) ... if it's a single SELECT
list, then I made it fail if option 0 was selected.
________________________________
From: Andrew Davidson [mailto:[EMAIL PROTECTED]
Sent: 13 July 2006 13:25
To: [email protected]
Subject: [CF-Dev] cfselect
>- see footer for list info -<
Am fixing up someone else's code, and they have a cfselect in
there
that is set required="yes", which doesn't work at all, in that the first
option in the select list, which is along the lines of "Please select an
option", still passes the required check (which it shouldn't).
I haven't used cfform much myself, so is this correct ? If it is, then
that
is pretty useless, isn't it ?
_______________________________________________
For details on ALL mailing lists and for joining or leaving lists, go to
http://list.cfdeveloper.co.uk/mailman/listinfo
--
CFDeveloper Sponsors:-
>- Hosting provided by www.cfmxhosting.co.uk -<
>- Forum provided by www.fusetalk.com -<
>- DHTML Menus provided by www.APYCOM.com -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help
-<
_______________________________________________
For details on ALL mailing lists and for joining or leaving lists, go to
http://list.cfdeveloper.co.uk/mailman/listinfo
--
CFDeveloper Sponsors:-
- Hosting provided by www.cfmxhosting.co.uk -<
- Forum provided by www.fusetalk.com -<
- DHTML Menus provided by www.APYCOM.com -<
- Lists hosted by www.Gradwell.com -<
- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<