Author Topic: Dynamic text  (Read 14261 times)

sparkyharibo

  • Newbie
  • *
  • Posts: 1
  • I'm a llama!
    • View Profile
Dynamic text
« on: April 17, 2013, 03:20:49 PM »
I want to display dynamic text on a webpage determined by the value of DM[1],

 ie DM[1]<100 print text 'A'
     DM[1]>100 print text 'B'

Do i need to play around with the Njs file to create a function for this? I'm not wanting to do that
if theres an easier option!


support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Dynamic text
« Reply #1 on: April 18, 2013, 12:28:33 AM »
The PLC could be the one checking the data and set the display on the LCD and your webpage can read it off the virtual LCD.

If you don't want the PLC to do the work, then you will need to write some Javascript to run periodically (e.g. tie to the continuous refresh timer) and check the data variable and then create dynamic display. You do need to be pretty strong Javascript programmer to attempt this.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Dynamic text
« Reply #2 on: April 18, 2013, 01:19:45 PM »
Hi Sparky,

I have got dynamic text working and a dynamic picture in a webpage I've developed.

The n.js file has been scrapped and all the js function are included in the HTML file.

I do see communication errors once in a while so I added some code to refresh the page every five minutes which helps keep the connection alive.

I think the next stage is to re-split my code back to a HTML and a js file but its work in progress  ;D

I'll post the code when I'm next in the office that I've used so you can play around with the functions and see what I've done.

I'm no JS or HTML expert, but if you find a good web page forum, most of the members are very helpful.

http://www.w3schools.com/html/default.asp this site is very good for general info

http://www.codingforums.com. The members here were very helpful.



BC SYSTEMS

  • Full Member
  • Posts: 146
    • View Profile
Re:Dynamic text
« Reply #3 on: April 19, 2013, 06:06:52 AM »
Hi Sparky,

See attached.

I have a datamem14 variable in the html code.

look at function modetext below.

******

function modetext() //IM NTC BB
{
i = document.getElementById('datamem14').value;
if (i == 1)
{
document.getElementById('modeIM').value = "Manual Mode";
}
else if (i == 2)
{
document.getElementById('modeIM').value = "Auto Mode";
}
else if (i == 3)
{
document.getElementById('modeIM').value = "Test Mode";
}
else
{
document.getElementById('modeIM').value = "Off Mode";
}
}

***********

Good Luck.

Marcus
« Last Edit: April 19, 2013, 06:07:56 AM by BC SYSTEMS »