如何填充一个下拉与从JavaScript值? [英] How to populate a drop down with values from JavaScript?
问题描述
我在扩展,套上CMS添加一个按钮功能区工具栏按钮。在点击按钮弹出一个页面将显示带有两个下拉菜单。在第一个下拉控制改变价值观,我应该为填充第二个下拉控件的值。就我而言,我使用 ASP下拉列表
控制。暂时我会很难code的值来填充到第二下降Java脚本了。对于这个要求,我用下面的code,但我不能来填充(不识别标签)的值。
I added a button to the ribbon toolbar button in my extension to the Tridion CMS. On click of the button a popup page will display with two drop downs. By changing the values in the first drop down control I should populate the values for second drop down control. In my case I am using ASP drop down list
control. For the time being I will hard code the values to be populated to the second drop down in java script. For this requirement I am using the following code but I am not able to populate the value (Not Identifying the tag).
Java脚本的code:
Java script code:
ABC.WCMS.RTFExtension.Popups.ButtonPopup.prototype._populate = function () {
var selectedValue = $('#functionalcomponent').value;//First dropdown selected value
var dropdownId = $("#Dd");//Second Dropdown Control
switch (selectedValue) {
case "Home Ware":
dropdownId.append($("<option> </option>").val("Select Sub-Category").html(""));
dropdownId.append($("<option> </option>").val("Air-Conditioners/Coolers").html("Air-Conditioners/Coolers"));
break;
case "Education":
dropdownId.append($("<option> </option>").val("Select Sub-Category").html(""));
dropdownId.append($("<option> </option>").val("Colleges").html("Colleges"));
break;
default:
dropdownId.append($("<option> </option>").val("Select Sub-Category").html(""));
dropdownId.append($("<option> </option>").val("No Value").html("No Value"));
}
return true;
}
ASPX控制:
ASPX Controls:
<%--Dropdown1--%>
<asp:DropDownList ID="functionalcomponent" runat="server"></asp:DropDownList>
<%--Dropdown2--%>
<asp:DropDownList ID="Dd" runat="server"></asp:DropDownList>
我怎样才能为填充第二滴值从外部JavaScript文件下来?
How can I populate the values for second drop down from external JavaScript file?
推荐答案
我最近在一个GUI扩展,我们填充下拉基于另一个下拉的价值的工作。当我填充使用javascript我有以下的code:
I recently worked on a GUI extension where we populated a drop down based on the value of another drop down. When I populate using javascript I have the following code:
$j(c.SystemDropDown).append("<option value=\"" + value + "\">" + value + "</option>");
正如你可以看到我的例子追加整个&LT;选项&GT;
标签,其中作为使用指定你的 .VAL()
,也许你可以试试这个办法吗?
As you can see my example appends the whole <option>
tag, where as yours is specified using the .val()
, perhaps you could try this way?
我的版本是伟大的工作:)
The version I have is working great :)
这篇关于如何填充一个下拉与从JavaScript值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!