使用在多重选择复选框中选中的数组创建新的移动页面

时间:2019-01-07 02:41:00

标签: javascript jquery arrays

我创建了一个多列表复选框表单,并试图将选定的值移到另一个移动页上,以便在选择选定的操作按钮时显示出来。我看到了一些针对弹出窗口的响应,而不是针对新的静态移动页面的响应。

  var k = 0;
        for (var i = 0; i < 300; i++) {
            var row = {};
            row["firstname"] = firstNames[k];


            data[i] = row;
            k++;
        }

        var source =
        {
            localdata: data,
            datatype: "array"
        };
        var dataAdapter = new $.jqx.dataAdapter(source);

        $('#dropdownlist').jqxDropDownList({
            selectedIndex: 0, checkboxes: true, theme: theme, 
    autoDropDownHeight: true, source: dataAdapter, 
    displayMember: "firstname", valueMember: "notes", 
    itemHeight: 70, height: 40, width: '90%',
            renderer: function (index, label, value) {
            var datarecord = data[index];
            var imgurl = '../../images/' + label.toLowerCase() 
    + '.png';
            var img = '<img height="50" src="' + imgurl + '"/>';
            var table = '<table><tr><td style="width: 55px;
    " rowspan="2">' 
    + '</td><td>' + datarecord.firstname + " " + '</td></tr><tr><td>'  
    + '</td></tr></table>';
                return table;
            }
        });
        initSimulator("dropdownlist");
    });
 </script>
 </head>
 <body class='default'>
 <div id="demoContainer" class="device-mobile">
    <div id="container" class="device-mobile-container">
     <h3 style="margin-left: 5%; margin-top: 
 20px;">Select employees:</h3>
        <div style="margin-left: 5%;" id="dropdownlist"></div>
     </div>
 </div>

 <input type="button" id="btnSelected" value="Get Selected" />

第二页代码,将用于捕获上面列出的代码的结果:

      <table id="dataAdapter" name = "firstnames" class="OutlinePage"> 

    <thead class="OutlineText">

    <tr>

    <td>Name</td>
    <td></td>
    <td></td>

    </tr>
    </thead>

    <tbody class=OutlineText">

    </tbody>

    </table>
    </div>
    </body>
    <script>

  function AddData() { 

   {

    var rows = "";

    var name = document.getElementById("firstnames").value;

   var position = document.getElementById("array").value;

    rows += "<td>" + name + "</td><td>" + position + "</td>";

    var tbody = document.querySelector("#list tbody");

    var tr = document.createElement("tr");

    tr.innerHTML = rows;

    tbody.appendChild(tr)

    //

    }

   }

   function ResetForm() {

    document.getElementById("firstnames").reset();

   }

   </script></h1>


   <script>
   // from checkboxes7.html
   document.getElementById("write").innerHTML = window.location.search;
    </script>


   <script>
   function getParameterByName(name, url) {
    if (!url) url = window.location.href;
   name = name.replace(/[\[\]]/g, '\\$&');
   var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
       results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
     return decodeURIComponent(results[2].replace(/\+/g, ' '));
      }</script>


      <script>
      function show() {
      document.getElementById("write").innerHTML = name;

       }

    var sn = getParameterByName('firstnames');

    document.getElementById("write").innerHTML = sn;

    </script>
      </p>

    </html>

1 个答案:

答案 0 :(得分:0)

许多事情还没有定义,没有合适的库我就无法测试。发现了一些语法问题,因此我对它们和代码进行了一些清理。

$(function() {
  var k = 0;
  for (var i = 0; i < 300; i++) {
    var row = {};
    row.firstname = firstNames[k];
    data[i] = row;
    k++;
  }

  var source = {
    localdata: data,
    datatype: "array"
  };
  var dataAdapter = new $.jqx.dataAdapter(source);

  $('#dropdownlist').jqxDropDownList({
    selectedIndex: 0,
    checkboxes: true,
    theme: theme,
    autoDropDownHeight: true,
    source: dataAdapter,
    displayMember: "firstname",
    valueMember: "notes",
    itemHeight: 70,
    height: 40,
    width: '90%',
    renderer: function(index, label, value) {
      var datarecord = data[index];
      var imgurl = '../../images/' + label.toLowerCase() + '.png';
      var img = '<img height="50" src="' + imgurl + '"/>';
      var table = '<table><tr><td style="width: 55px;" rowspan="2">';
      table += '</td><td>' + datarecord.firstname + " " + '</td></tr><tr><td>';
      table += '</td></tr></table>';
      return table;
    }
  });
  initSimulator("dropdownlist");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="demoContainer" class="device-mobile">
  <div id="container" class="device-mobile-container">
    <h3 style="margin-left: 5%; margin-top: 20px;">Select employees:</h3>
    <div style="margin-left: 5%;" id="dropdownlist"></div>
  </div>
</div>

<input type="button" id="btnSelected" value="Get Selected" />

希望有帮助。