How to retrun variable value to the js?

43 Views Asked by At

I want to return the value of P221_JSON_PROCESS item to the variable and then return the value to the new vis.DataSet. I tried as follows:

// P221_JSON_PROCESS contains - { id: 1, label: "Node 1" },

function returnNodes() {
var process = document.getElementById("P221_JSON_PROCESS").value;
return process;
} 

var nodes = new vis.DataSet([
  returnNodes();
]);

// create an array with edges
var edges = new vis.DataSet([
]);

// create a network
var container = document.getElementById("mynetwork");
var data = {
  nodes: nodes,
  edges: edges,
};
var options = {};
var network = new vis.Network(container, data, options); 

Thanks in advance!

1

There are 1 best solutions below

0
Dindayal Dhakar On

You can use add method like

var nodes = edges.add([returnNodes()]);

or

var nodes = new vis.DataSet([,returnNodes()]);