Mitsubishi Electric MELSEC iQ-RJ71EN71 User Manual page 171

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>Device write CGI 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>
function WriteDeviceBlockTbl(devtblid, row) {
var dataitem;
var xhr;
var devtblitem = document.getElementById(devtblid);
// Number of device points setting (fixed to one point)
var param = 'NUM=1&';
// Parameter setting of the device name
var devitem = document.getElementById(devtblitem.rows[row].cells[0].childNodes[0].id);
param += 'DEV1=' + devitem.value + '&';
// Parameter setting of the device size
var typitem = document.getElementById(devtblitem.rows[row].cells[1].childNodes[0].id);
if( 'Bit' == typitem.value){
param += 'TYP1=' + 'B';
}
else if( '16-bit Integer' == typitem.value) {
param += 'TYP1=' + 'W';
}
else if( '32-bit Integer' == typitem.value) {
param += 'TYP1=' + 'D';
}
else {
param += 'TYP1=' + 'Q';
}
param += '&';
// Parameter setting of the data
var dataitem = document.getElementById(devtblitem.rows[row].cells[2].childNodes[0].id);
param += 'DATA1=' + parseInt(dataitem.value).toString(16)
// Request to the CGI
xhr = new XMLHttpRequest();
xhr.open('POST', "/cgi/WrDev.cgi", true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var FUNC = function() { WriteDeviceBlockTbl_Response(xhr, typitem, dataitem); }; // Response analysis function setting
xhr.onreadystatechange = FUNC;
xhr.send(param);
}
1 FUNCTIONS
169
1.12 Web Server Function
1

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents