This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Show control inline in PC/Tablet
#27
(10.10.2018, 00:17)Erwin van der Zwart Wrote: Hi,

Try this: 

I used the tag 'String' to select the tagged objects and changed from .html to .lp for support of client side LUA.
Code:
-- use this path in your iframe: /user/input.lp

dst = '/www/user/input.lp'
io.writefile(dst, [[
<!DOCTYPE html">
<head>
 <script type="text/javascript" src="/scada/vis/jquery.js.gz"></script>
 <script src="/apps/js/localbus.js.gz"></script>
 <script src="/scada/vis/busdecode.js.gz"></script>
 <style type="text/css">
   body {
       background-color: transparent;
   }
   .inputlabel{
     display: inline-block;
     width: 150px;
       max-wid2h: 200px;
     margin-left: 10px;
   }
   .stringinput{
       width: 240px;
     margin-left: 10px;
     margin-top: 5px;
   }
   .savebtn{
       width: 120px;
     margin-left: 50px;
   }

 </style>
</head>
<body>
 <?
   require('apps')
 ?>
 <script>
 localbus.init();
 var objects = <? json.write(grp.tag('String')) ?>;

 function createInput(name, address, id){
    var $input = $('<label id="label_' + id + ' " class="inputlabel">' + name + '</label><table width="100" border="0"><tr><input id="input_' + id + '" class="stringinput" type="text" maxlength="255" /></tr><tr><input id="button_' + id + '" class="savebtn" type="button" value="Save" /></tr></table>');
    $input.appendTo($("body"));
 }
 
 function addevent(address, id){
   $("#button_" + id).data("address", address);
   $("#button_" + id).data("id", id);
   $("#button_" + id).on( "click", function(e) {
      localbus.write(address, $("#input_" + $(e.target).data('id')).val());
   });
  }
 
 for (var i in objects) {
   createInput(objects[i].name, objects[i].address, objects[i].id);
 }
 
 $(document).ready(function() {
   for (var i in objects) {
     addevent(objects[i].address, objects[i].id);
     $("#input_" + objects[i].id).val(objects[i].value);
   }
 });
 
 </script>
</body>
</html>
]])
script.disable(_SCRIPTNAME)
BR,

Erwin

Hi Erwin

Just tested this now, worked like a charm! Thanks a lot for the support!

Now, only one more question;
I think I will use this script in a lot of projects. And then also for read only objects. Is there a way to set one field as read only? The save button part, I guess I can just leave out in that case, but I may not always want the customer to be able to edit the values.

And one more question; 
In future projects, I might need a different sorting order. Is that something that can be added also?

BR
Trond
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply


Messages In This Thread
Show control inline in PC/Tablet - by Mirco - 26.01.2017, 06:51
RE: Show control inline in PC/Tablet - by Trond Hoyem - 12.10.2018, 07:03

Forum Jump: