Link to home
Start Free TrialLog in
Avatar of ehart12
ehart12Flag for United States of America

asked on

Coldfusion bindonLoad validate with two Text Fields?

I have CFFORM that is setup with two independent bindonLoad fields like shown below. Both fields validate data against a database query.

The first text field is called ITEM and the second text field is called GROUP.  I need to add extra validation in the query on the GROUP field.  I need to bring in the text entered from the ITEM field into the GROUP query.  I hope that makes sense...

I am not sure if ColdFusion will get me there, so I am open to other methods...


   Form:
         <form>
                 Item <input type="text" name="item" id="item">
                 <cfdiv bindonLoad="false" bind="url:checkItem.cfm?item={item@blur}">
                 Group <input type="text" name="group" id="group">
                 <cfdiv bindonLoad="false" bind="url:checkGroup.cfm?group={group@blur}">
                 Next field <input type="text" name="otherField">
         </form>

        checkItem.cfm:
         <cfparam name="url.item" default="">
         <cfquery name="findRecord" ...>
                 SELECT  Description
                 FROM   YourTable
                 WHERE  item = <cfqueryparam value="#url.item#" cfsqltype="cf_sql_varchar">
         </cfquery>


        checkGroup.cfm:
         <cfparam name="url.group" default="">
         <cfquery name="findRecord" ...>
                 SELECT  Description
                 FROM   YourTable
                 WHERE  group = #url.group#
                 AND      item = <somehow pulled from item field???>
         </cfquery>

Thank you,

Eric
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ehart12

ASKER

Worked great! Thank you...
So you could skip the query unless group is non-empty

I just remembered you could also use @none. Then the div refresh only triggers when leaving the group field:

<cfdiv bindonLoad="false"
           bind="url:checkGroup.cfm?group={group@blur}&item={item@none}">