后面添加:
赞
踩
101-opcuaitem.html:
在:
<script type="text/x-red" data-template-name="OpcUa-Item">
后面添加:
- <div class="form-row">
- <label> Selector</label>
- <select id="opcualist" name="opcualist1"></select>
- </div>
在该script最后添加:
- <script type="text/javascript">
- //该步骤必须等到上面的select完成加载才能使,位置只能在这。每次双击打开该页面都会执行该操作
- $(document).ready(function(){
- updateopcualist();
- });
- </script>
在:
<script type="text/javascript">
添加:
- function updateopcualist()
- {
- var opcualistItem = document.getElementById("opcualist");
- var opcuainputItem = document.getElementById("node-input-item");
- var opcuaTypeItem = document.getElementById("node-input-datatype");
- $.ajax({
- headers: {
- "Accept": "application/json"
- },
- dataType: "json",
- cache: false,
- url: 'aheadgetOpcuaFileContent',
- success: function (data) {
- opucalists = data["list"]
- var muloption = "";
- for (var key in opucalists) {
- var item = opucalists[key]; //["ns=1;s=xxx","Boolean"]
- muloption = muloption + "<option value=" + item + ">" + key + "</option>"
- }
- opcualistItem.innerHTML="<option value='0'>--select--</option>" + muloption;
-
- opcualistItem.onchange = function () {
- var results = opcualistItem.value.split(',');
- opcuainputItem.value = results[0];
- //设置类型
- for (i = 0; i < opcuaTypeItem.length; i++) {
- if (opcuaTypeItem[i].value == results[1]) {//value
- opcuaTypeItem[i].selected = true;
- break;
- }
- }
- }
- },
- error: function(jqXHR,textStatus,errorThrown) {
- console.log("get Opcua File Content Failed");
- }
- });
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。