locked
How to append a checkbox to Option Value RRS feed

  • Question

  • User457850011 posted

    I am trying to append checkbox to an option value when an item is selected but I can't seem to find a away. Below is my code and sample output without the checkbox

    so I need to add a checkbox before the "value" <option value="' ;

    <div class="col-md-6">
    <div id="selectDescription">Select Employees(s) or Administrators</div>
    <div>
    <select name="wd" id="wdSelect" style="width: 80%;" multiple="" class="form-control select-checkbox" size="10">
    <option value="default" disabled>
    None
    </option>
    </select>
    </div>
    <div>
    <input name="chkSelectAll" id="chkSelectAll" type=checkbox value="" style="display:inline-block;" />
    <label for="chkSelectAll" style="display:inline-block;"> Select All </label>
    </div>
    </div>

    $('#Report').change(function () {

    var empId = $("#Report").val();
    var _tt = $(this).val();
    $('#wdSelect').empty();
    $.ajax({
    type: "GET",
    dataType: "json",
    url: "/Report/LoadReport",
    data: {empId: reportId },
    success: function (data) {

    if (data.selectedwd.length > 0) {
    $('#selectDescription').html("Select Employees(s) or Administrators");
    $("#wdSelect")[0].name = 'wd';
    $.each(data.selectedwd, function(i, wd) {
    $("#wdSelect").append('<option value="'
    + wd.Value + '">'
    + wd.Text + '</option>');
    });
    } else {
    $('#selectDescription').html("Select Admins");
    $("#wdSelect")[0].name = 'admin';
    $.each(data.selectedadmin, function (i, wd) {
    $("#wdSelect").append('<option value="'
    + wd.Value + '">'
    + wd.Text + '</option>');
    });
    }
    },

    Tuesday, October 29, 2019 7:12 PM

Answers

  • User-474980206 posted

    your question is not clear. are you trying to add a checkbox to an option? if so, this is not supported. You will need to switch to javascript component that has this feature. its pretty common with select / dropdown components.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 29, 2019 7:47 PM

All replies

  • User-474980206 posted

    your question is not clear. are you trying to add a checkbox to an option? if so, this is not supported. You will need to switch to javascript component that has this feature. its pretty common with select / dropdown components.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 29, 2019 7:47 PM
  • User457850011 posted

    Hi bruce 

    Yes I am trying to add a checkbox to the option. Thanks let me see what I can get 

    Tuesday, October 29, 2019 9:42 PM