如何显示列表<字符串>在 html 选择控件中

发布于 2024-11-04 11:31:03 字数 1810 浏览 1 评论 0原文

我必须在拖放列时绑定 html 选择中的列表。以下是我获取 list 的函数

    var oper;
   function FunctionScript() {
  $.ajax({
      type: "POST",
      url: "Webtop.aspx/FunctionDropdown",
      data: {},
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(msg) {
          $("#ddOperators").empty();
          for (var i = 0, l = msg.d.length; i < l; i++) {
              $("#ddOperators").append("<option>" + msg.d[i] + "</option>");
              oper = msg.d;
              alert("Check Dropdown");
          }
          alert('Check Operator DropDown' + msg.d.length);
      }, 
      error: DisplayError 
  });


}

//以下函数用于拖放。

     function handleDropEvent(event, ui) {
      var draggable = ui.draggable;
      var uid = removeSpaces(draggable.attr('text'));
      FunctionScript();
      var colName = draggable.attr('title');
      $('#selectedColumns > tbody:last').append('<tr id="' + uid + '"><td></td>
<td><input type="checkbox" id="chk" checked="checked" /></td><td><label>' + colName + '</label></td><td><input type="text" /></td><td><a href="#">Delete</a></td>
    <td><select title="select table" id="ddOperators"/></td><td><input type="text" /></td>
     <td><div><input type="text" value="" size="20" name="txtForeColor"/><a id="pick2" name="pick2" href="#">Select Color</a></div></td><td></td></tr>');
          $("#selectedColumns").tableDnD({ onDragClass: "DragClass" });

    }

select的id是ddOperators;目前,选择不与list绑定。

I have to bind the List in html select upon drag drop of the columns. The following is my function to get list<string>

    var oper;
   function FunctionScript() {
  $.ajax({
      type: "POST",
      url: "Webtop.aspx/FunctionDropdown",
      data: {},
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(msg) {
          $("#ddOperators").empty();
          for (var i = 0, l = msg.d.length; i < l; i++) {
              $("#ddOperators").append("<option>" + msg.d[i] + "</option>");
              oper = msg.d;
              alert("Check Dropdown");
          }
          alert('Check Operator DropDown' + msg.d.length);
      }, 
      error: DisplayError 
  });


}

//The following function is used for dragdrop.

     function handleDropEvent(event, ui) {
      var draggable = ui.draggable;
      var uid = removeSpaces(draggable.attr('text'));
      FunctionScript();
      var colName = draggable.attr('title');
      $('#selectedColumns > tbody:last').append('<tr id="' + uid + '"><td></td>
<td><input type="checkbox" id="chk" checked="checked" /></td><td><label>' + colName + '</label></td><td><input type="text" /></td><td><a href="#">Delete</a></td>
    <td><select title="select table" id="ddOperators"/></td><td><input type="text" /></td>
     <td><div><input type="text" value="" size="20" name="txtForeColor"/><a id="pick2" name="pick2" href="#">Select Color</a></div></td><td></td></tr>');
          $("#selectedColumns").tableDnD({ onDragClass: "DragClass" });

    }

The id of select is ddOperators; Currently the select does not bind with the list<strings>.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假扮的天使 2024-11-11 11:31:04

在您的脚本中进行以下更改。

替换

 var draggable = ui.draggable;

 var draggable = ui.draggable({helper:'clone'});

Do the following changes in your script.

replace

 var draggable = ui.draggable;

with

 var draggable = ui.draggable({helper:'clone'});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文