Javascript Example - Mitsubishi Electric MELSEC iQ-RJ71EN71 User Manual

Ethernet
Hide thumbs Also See for MELSEC iQ-RJ71EN71:
Table of Contents

Advertisement

• JavaScript example

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- charset setting*Set UTF-8 which is set in the Web server setting -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<!-- Set the title name -->
<title>Sample</title>
<link href="./css/UserWebStyle.css" rel="stylesheet" media="all" />
<!-- Library JavaScript reading (change the path depending on the storage position) -->
<script src="./RUserWebLib.js"></script>
<!-- Write the original JavaScript hereinafter -->
<!-- Write the JavaScript of the user here -->
<script>
// The function for a CGI request
function ReadDeviceRandomTbl(devtblid) {
var devtblitem = document.getElementById(devtblid);
var i, devitem, typitem;
var tblrows = devtblitem.rows.length;
var param;
// Number of device points setting
param = "NUM=" + (tblrows - 1) + '&';
for (i = 1; i < tblrows; i++) {
// Parameter setting of the device name
devitem = document.getElementById(devtblitem.rows[i].cells[0].childNodes[0].id);
param += devitem.name + "=" + devitem.value + '&';
// Parameter setting of the device size
typitem = document.getElementById(devtblitem.rows[i].cells[1].childNodes[0].id);
if( "Bit" == typitem.value) {
param += typitem.name + "=" + 'B';
}
else if("16-bit Integer" == typitem.value) {
param += typitem.name + "=" + 'W';
}
else if("32-bit Integer" == typitem.value) {
param += typitem.name + "=" + 'D';
}
else {
param += typitem.name + "=" + 'Q';
}
if( i < (tblrows - 1)) param += '&';
}
// Request to the CGI
xhr = new XMLHttpRequest();
xhr.open('POST', "/cgi/RdDevRnd.cgi", true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var FUNC = function() { ReadDeviceRandomTbl_Response(xhr, devtblid); }; // Response analysis function setting
xhr.onreadystatechange = FUNC;
xhr.send(param);
}
1 FUNCTIONS
163
1.12 Web Server Function
1

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents