0

My webpage displays realtime data that is updated every 10 seconds from our PI server(historian server). I was recently tasked to take two peices of data that are allready displayed on my page and divide them, displaying the new result on a graph. I have very little experience with AJAX/JQuery, so I was wondering if someone out there can lend me a hand?

Clarification:

Hypethetically-

Say I have "Number of Grades" and "Sum of Grades" displayed on my page as basic integers. They are updated every 10 seconds from the server. I want to take those two pieces of live data, divide them, and display the result (in this case it would be the overall average grade). So, my page will display Number of Grades, Sum of Grades, and Average Grade all updated in real time, every 10 seconds.

I am unclear as to whether JQuery can simply take those values off the server and perform division on them and return a value, or if other steps need to be taken to achieve this. I'm completely shooting in the dark here so sorry in advance for any vagueness or lack of required information.Thank you. Some example code is given below:

<span class = 'PIdata' data-tag = 'NumOfGrades' data-on_pi_change = 'NumOfGradeChange'></span>

<span class = 'PIdata' data-tag = 'SumOfGrades' data-on_pi_change = 'SumOfGradeChange'></span>

I want to display a value that divides NumOfGrades by SumOfGrades.

2
  • 1
    Please give an actual example of the expected input, and the desired output based on that input. Commented Jul 5, 2012 at 14:48
  • An actual example would be 'ActualProcessSpeed'( 200) and 'AimedSpeed'(225). I would need to output (200/225 or 89) to the page. The ActualProcessSpeed and AimedProcessSpeeds would be values taken directly from the historian server. Commented Jul 5, 2012 at 15:07

2 Answers 2

0
var sumOfGrades = parseFloat($.('#SumOfGradesId').text());
var numberOfGrades = parseFloat($.('#NumberOfGradesId').text());

var result = fn(sumOfGrades , numberOfGrades);

$.('#AverageGradeId').text(result);

This will set the required value.

Sign up to request clarification or add additional context in comments.

Comments

0

Simple Maths with jQuery - division

The above link seems to have the answer to your question! Basically just access numbers by their id you set, get the value, parse them into integers or floats, perform your calculation, then store the value into the spot you would like it to appear!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.