We are trying to validate a text box name called PRODUCT FAMILY.We are currently writing a query to fetch the count of that particular PRODUCT FAMILY.The query is given below:
select count(*) prod_cnt from pcw.pcw_pmview_int where cnumber_desc ='#sPcwAcc#'
Prod family #prod_count#
How do i include the above code in my java script validation function using coldfusion so that When we enter the PRODUCT FAMILY which is not in the database(invalid data) the count would be zero.So the error mesg shud pop up and also the query r开发者_Python百科uns first before the validation as we want the present count of that text box that is PRODUCT FAMILY???
You'll need to do an AJAX request to a ColdFusion page or CFC, whcih will run that query based on the user's input.
There are lots of ways you can do this. ColdFusion, Ajax, and auto-complete style functionality would be my first choice. This way you can have the user type and only valid data is populated. If you are using CF8/CF9 its easy. You could then check if data is null using javascript
if(data.PRODUCT!= null) document.getElementById('product').value = data.PRODUCT;
I don;t like posting links but Ray has a good post on this I would recommend here: http://www.coldfusionjedi.com/index.cfm/2008/4/21/Ask-a-Jedi-Extending-ColdFusions-autocomplete-feature
On another note: In your example you should 'always' wrap query string parameters with cfqueryparam for security reasons. I just noticed this.
精彩评论