>- see footer for list info -<
IF you can/want to change the cfform.js, thhe fix I did also works,
without having to check for a space, or add a space ass the value for
the first option ...
 
cfform.js ORIGINAL ...
else if (obj_type == "SELECT")
{
    for (i=0; i < obj.length; i++)
    {
        if (obj.options[i].selected)
        return true;
    }
    return false; 
}
 
What I changed it to (only a few extra lines) ...
else if (obj_type == "SELECT")
{
    if(obj.multiple) {
        StartFrom=0;
    }
    else {
        StartFrom=1;
    }
    for (i=StartFrom; i < obj.length; i++)
    {
        if (obj.options[i].selected)
        return true;
    }
    return false; 
}


________________________________

        From: Charlie Arehart [mailto:[EMAIL PROTECTED] 
        Sent: 13 July 2006 16:18
        To: 'Coldfusion Development'
        Subject: RE: [CF-Dev] cfselect
        
        

        >- 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/comm
on/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 -< 


        
************************************************************************
**** Notice: This e-mail and any attachments are confidential and may
contain legally privileged information and/or copyright material of
Hansen Technologies Limited or third parties.  Copying, distributing,
disclosing, commercialising or otherwise acting in reliance on this
e-mail and any attachments is strictly prohibited unless you are the
addressee of this e-mail and have written permission to do so.  If you
have received this e-mail in error please delete this e-mail (including
any copies and attachments) and contact Hansen Technologies Limited by
return e-mail or by telephone on + 61 39840 3000.  Any views expressed
in this e-mail are those of the individual sender and may not
necessarily reflect the views of or be a commitment by the organisation,
except where the individual sender has the authority and expressly
states them to be so.
************************************************************************
****

_______________________________________________

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

Reply via email to