ehart12
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?it em={item@b lur}">
Group <input type="text" name="group" id="group">
<cfdiv bindonLoad="false" bind="url:checkGroup.cfm?g roup={grou p@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
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?it
Group <input type="text" name="group" id="group">
<cfdiv bindonLoad="false" bind="url:checkGroup.cfm?g
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?g roup={grou p@blur}&it em={item@none}">
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?g
ASKER