Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Example: Creates PmForm window with data entry items

In a single script (e.g. after pressing the button in the onButtonUp event) a form is created, set and open:
JavaScriptSelect and copy to clipboard

var oNmb1, oBool1, oEnum1, oStr1, oBtn1;

function onViewLoad(ev)
{
//Creates a form object
var oForm = ev.Form;
oForm.Title = "Setting";

//Creates form items (Pmf objects)

//PmfNumber
oNmb1 = oForm.CreateItem("number", "n1", "Number of packages", "Min:0;Max:33;");
oNmb1.Value = 5;

//PmfBool
oBool1 = oForm.CreateItem("bool", "b1", "Store");
oBool1.Value = true;

//PmfEnum
oEnum1 = oForm.CreateItem("enum", "e1", "Processing speed");
oEnum1.AddRow(0.5, "slow");
oEnum1.AddRow(9.9, "fast");
oEnum1.Value = 0.5;
oEnum1.AddEvent("onEditAccept", onEAccept);

//PmfString
oStr1 = oForm.CreateItem("string", "s1", "Description");
oStr1.Value = "Packed water";

//PmfButton
oBtn1 = oForm.CreateItem("button", "reset", "Zero in");
oBtn1.Value = "Reset";
oBtn1.AddEvent("onAction", onReset);

//AddEvent
oForm.AddEvent("onClose", onViewClose);
}


function onEAccept(ev)
{
if (oEnum1.Value == 9.9)
oStr1.Value = "fast - Packed water";
}


function onReset(ev)
{
if (ev.Action == "main")
{
oNmb1.Value = 5;
oBool1.Value = true;
oEnum1.Value = 0.5;
oStr1.Value = "Packed water";
}
}


function onViewClose(ev)
{
if (ev.CloseReason == "ok")
Pm.Debug(oNmb1.Value + ", " + oBool1.Value + ", " + oEnum1.Value);
}


//Creates PmViewCreator - This object allows opening the various viewers
var oCreator = Pm.CreateView(pMe.PmPanel, "/#glob/form", "", "target:_blank;modal:1;pos:view," + pMe.ViewX + "," + pMe.ViewY + ";");
oCreator.View.onLoad = onViewLoad;

//Opens form in modal window:
oCreator.Open();
PROMOTIC 9.0.12 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice