1

这篇文章解决了我遇到的问题。

Coldfusion 8 同时执行 CFIf 和 CFElse 语句

Mycfselect绑定到 CFC 以动态构建其数组。好的,现在我想添加一个数组项“--New Record--”,当它被选中时,跳转cflocation到允许用户在源表中添加新记录的表单。我可以在列表中看到“--New Record--”条目cfselect,但选择它似乎什么也没做。

但实际上,cflocation转到目标页面(我有 OnRequestEnd 日志证明)但目标页面的形式没有显示。

看起来这个话题在上面的讨论中没有得到解决。Ben Nadel 的博客强调了<cflocation>行为的变化,但我是新手,所以我不认为理解其中的含义或如何绕过功能变化。对于如何围绕这种(奇怪的)行为变化进行编码的任何帮助将不胜感激。

TIA。

4

1 回答 1

0

In your cfc, change your query from something like this:

    SELECT  id_field, text_field
    FROM    sometables
    WHERE   ... 

to

    SELECT   -1 AS id_field, 'Add New Record' AS text_field
    FROM     some_small_table
    WHERE   ... 
    UNION
    SELECT   id_field, text_field
    FROM    sometables
    WHERE   ... 
    ORDER BY id_field

That way your bind will still work and you will have your "Add New Record" selection.

Next, add an onBlur attribute to your cfselect. Have it call a javascript function that directs the user to the appropriate place if they select "Add New Record".

于 2013-02-02T23:46:05.333 回答