我们正在尝试验证名为“产品系列”的文本框名称。我们当前正在编写一个查询来获取该特定产品系列的计数。查询如下:
从 pcw.pcw_pmview_int 选择 count(*) prod_cnt
其中 cnumber_desc ='#sPcwAcc#'
产品系列#prod_count#
我如何使用coldfusion将上述代码包含在我的java脚本验证函数中,以便当我们输入不在数据库中的产品系列(无效数据)时计数将为零。因此错误消息会弹出并且查询也会弹出在验证之前首先运行,因为我们想要该文本框的当前计数,即产品系列???
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 runs first before the validation as we want the present count of that text box that is PRODUCT FAMILY???
发布评论
评论(2)
您需要向 ColdFusion 页面或 CFC 发出 AJAX 请求,CFC 将根据用户的输入运行该查询。
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.
有很多方法可以做到这一点。 ColdFusion、Ajax 和自动完成样式功能将是我的首选。这样您就可以拥有用户类型并且仅填充有效数据。如果您使用 CF8/CF9,则很简单。然后,您可以使用 javascript 检查数据是否为空,
我不喜欢发布链接,但 Ray 在这方面有一篇很好的文章,我会在这里推荐:http://www.coldfusionjedi.com/index.cfm/2008/4/21/Ask-a-Jedi-Extending-ColdFusions-autocomplete-feature
另请注意:在您的示例中出于安全原因,您应该“始终”使用 cfqueryparam 包装查询字符串参数。我刚刚注意到这一点。
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
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.