0

我正在尝试将Ideal Forms用于我正在开发的新响应式网站。我目前有一个无线电选择器和两个下拉选择器。我正在尝试使用通过 cfc 查询的数据填充选择器。我为此编写的 jquery 可以工作,因为我有另一个使用它的站点,但没有使用理想的形式。当我在新页面上运行脚本时,一切正常,没有出现错误,返回的数据是格式正确的 json,但没有填充列表。

这是表格:

<form id="form1">
    <div>
        <section name="Basic Search">
            <div id="radioDiv">
                <label>Radio Buttons:</label>
                    <label><input type="radio" name="r1" id="value_1" value="1" checked />1</label>
                    <label><input type="radio" name="r1" id="value_2" value="2"/>2</label>
                    <label><input type="radio" name="r1" id="value_3" value="3"/>3</label>
            </div>
            <div id="selectDiv1">
                <label>Select 1:</label>
                <select name="select1" id="select1">
                    <option value="all">All</option>
                </select>
            </div>
            <div id="selectDiv2">
                <label>Select 2:</label>
                <select name="select2" id="select2">
                    <option value="all">All</option>
                </select>
            </div>
        </section>
    </div>
</form>

这是jQuery:

$.fn.populateListsBasic = function(){
    $.get("../cfc/mycfc.cfc",{
        method: "getData",
        data: conditionGroup.filter(':checked').val()
        },function(data){
            $.each(data.stuff.otherStuff1,function(key,value){
                $("#select1").append("<option value='" + value + "'>" + value + " (" + data.stuff.otherStuffCount_1[key] + ")</option>");           
            });
            $.each(data.stuff.otherStuff2,function(key,value){
                $("#select2").append("<option value='" + value + "'>" + value + " (" + data.stuff.otherStuffCount_2[key] + ")</option>");
            });
       },"json");
};

$("#form1").populateListsBasic();   

任何帮助,将不胜感激。

4

1 回答 1

0

不是真正的 Coldfusion 问题,但是.... #makes 来自哪里?我在您的表单中的任何地方都没有看到该 ID?不应该是:

 $.each(data.stuff.otherStuff2,function(key,value){
                $("#select2").append("<option value='" + value + "'>" + value + " (" + data.stuff.otherStuffCount_2[key] + ")</option>");
            });
于 2013-08-20T19:45:07.333 回答