在Checkboxes中显示数组的部分? [英] Display parts of an array in Checkboxes?
问题描述
嘿,我想知道如何在复选框中显示数组的某些部分。我的例子是我有一个选择框,当选择某个值时,我希望能够显示它与另一个相同的那个数组的某些部分。如果需要,可以创建一个快速JSFiddle。
var PRIVILEGE_PROFILES = [
{PROFILE_ID: ADickinson,COMPANY_CODE: GW,PRIVILEGE_CODE:( ALeave, ALVwBlkLV, ALAdmin, DAAppAccess),SECTOR: 01}
];
这是我的选择框中显示的数组,当选择了PROFILE_ID时我希望将所有不同的PRIVILEGE_CODES显示在一个内的多个复选框中DIV。但是,PRIVILEGE_CODE必须与此数组中的UNIQUE_CODE匹配,然后在复选框中显示privilege_code / unique_code,我需要显示SEC_PRIVILEGES.Name。
var SEC_Privileges = [
{Unique_Code:ALeave,名称:年假访问},
{Unique_Code:ALVwBlkLV,姓名:年假Blcok LeaveAccess},
{Unique_Code:AlAdmin ,姓名:年假管理员},
];
这是我的实际选择框的代码,我已经完成了用PROFILE_ID填充它的方法
var profileselectHTML = < select name ='select_profile'id ='select_profile'class ='form_drop_down'data-role ='none'> +
< option>无< / option>;
< blockquote>
为下拉列表添加一个onchange事件并添加以下代码并在html中添加一个div作为复选框的容器
( #select_profile)。change( function (){
var checkboxes = ;
( #select_profile选项:选中)。each( function (){
var value =
Hey, I was wondering how you go about displaying certain parts of an array in checkboxes. My example is that I have a select box, when a certain value is selected I want to be able to display certain parts of that array it has in common with another. Can create a quick JSFiddle if needed.
var PRIVILEGE_PROFILES = [
{ PROFILE_ID: "ADickinson", COMPANY_CODE: "GW", PRIVILEGE_CODE: ("ALeave", "ALVwBlkLV", "ALAdmin", "DAAppAccess"), SECTOR: "01" }
];
That's the array that is displayed in my select box, when the PROFILE_ID is selected I want to display all the different PRIVILEGE_CODES it has into multiple check boxes inside a div. However the PRIVILEGE_CODE must match with a UNIQUE_CODE from this array then instead the privilege_code/unique_code being displayed in the checkboxes I need SEC_PRIVILEGES.Name to be displayed instead.
var SEC_Privileges = [
{ Unique_Code: "ALeave", Name: "Annual Leave Access" },
{ Unique_Code: "ALVwBlkLV", Name: "Annual Leave Blcok LeaveAccess" },
{ Unique_Code: "AlAdmin", Name: "Annual Leave Admin" },
];
This is the code for my actual select box, I've already done the methods to populate it with PROFILE_ID's
var profileselectHTML = "<select name='select_profile' id='select_profile' class='form_drop_down' data-role='none'>" +
"<option>None</option>";
解决方案 Hi,
Add a onchange event for the dropdown and added the following code and add a div in html as container for the checkboxes
("#select_profile").change(function () {
var checkboxes = "";
("#select_profile option:selected").each(function () {
var value =
这篇关于在Checkboxes中显示数组的部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!