Dear Phoenix community I am trying to write on a variable using web page to PLC next, i have used the training material of Sliderder demo as an example, i made the same construction as it is explained and as well same javascript code to write on my PLCnext application, but i end up without success, but when i change the PLCnext application with the slider demo application i can write a value on that same variable. the only problem is it doesn’t work on my own PLC next application. Can anybody tell me what might went wrong in this case? what are the basic do’s and don’t on HTML tags. Thank you very much in advance.
Hello, Sorry to ask, but can you please give the link to the “Slider” training module you are following? (we have so many tutorials and training modules!) - Martin.
I’m really sorry, but I still don’t know where you found this example … is it somewhere on our website? From the screen shot it looks like it may have come from someone in the Netherlands … ? If I can find out where this example came from, I can get the right people here to help.
Yes it comes from the Netherlands I used the above example to write a variable called HTMLSlidervalue in PLC next, My plcnext application is configured the same way as the Slider demo example from the training material, the variable is as “External” declared and as well i have declared the same variable in the HMI webserver and connected it with the PLC variable. it is completely a same configuration as the training material, but i can’t write on the variable. please help me, what can possibly went wrong. Thank you again in advance
Hello, When trying to write variables from a webpage using the Javascript examples you have to make sure of a couple things:
1. In PLCnext engineer you have to create for the variable you want to write a HMI tag. Do this by making an external variable in your code worksheet. Then in the Global variable list you can find your external variable and you can select with right mouse button "add HMI tag". Without this Tag you are unable to write a variable 2. The variable name you gave the variable has to correspond perfectly with the Javascript code. In the code example you provided it's "HTMLSliderValue". So this value will be written or read. When you change the name in your program you'll have to do the same for the name used in Javascript code. 3. Make sure you are connecting to the right IP address in the JS code. In the example is a neat trick. In the beginning of the HTML form is the following:
It copies the url you use in your web browser and uses that to connect to the PLC! Then in the JS code it uses that variable to create a new url to connect to:
When you this combination of code is incomplete you will end up connecting to nothing and therefore can’t get any variables. I hope this can help you further! - Tristen
Dear tristen Thank you for your reaction. I have done exactly the same as you mentioned(please see the figures below). The IP address is correctly configured because i can read from the plc to my web application now the problem is writing to the PLC. Note: with the same JS code i showed above i can write on the same variable of the training slider demo .pscwex application(HTMLSliderValue). now the problem is when i load my pscwex application i can only read from the PLC (eg Stoingwebsite and Standwebsite i can read the values)but can’t write to the variable"HTMLSliderValue". Note: One thing i noticed is when i load the training slider demo app to the controller the Ehmi files will be created, while i load my app there is no Ehmi folder in the controller. Thank you in advance. 1-varible for HTML tag 2-global varible
3-HMI webserver
Hello Berne, Yes it seems the HMI variables are activated only when you have an active HMI page running on the controller. That’s why the example of the Slider has it as well. When you add an HMI page and insert there ( for example) a button the HMI tags are activated. Then you are able to write variables! With kind regards, Tristen

