On 09/08/2013 07:53, e...@cleantechsolution.in wrote:
I have written the following program
#!c:\Python27\Python.exe
import cgi, cgitb;
import sys, serial
cgitb.enable()
ser = serial.Serial('COM27', 9600)
myvar = ser.readline()
print "Content-type:text/html\n\n"
print """
<html>
<head>
<title>
Real Time Temperature
</title>
   <script type="text/javascript">
     window.onload = startInterval;
     function startInterval()
     {
         setInterval("startTime();",1000);
     }

     function startTime(myvar)
     {
         document.getElementById('mine').innerHTML ="Temperature" 
+parseInt(myvar);

     }
   </script>
</head>
<body>
<h1>Real Time Temperature:</h1>
<div id="mine"></div>
</body></html>
"""

It is giving an output of 'NaN' in the output.
If the python program is run alone it is giving the correct output.
Can anyone please help.
Is it also possible to separate the python and the javascript to two different 
files. If so how will I get/transfer the data in/from HTML .
Thanks

At a guess I'd say that it's because you have:

    setInterval("startTime();",1000);

which will call 'startTime' with no arguments, but:

    function startTime(myvar)

which means that it's expecting an argument.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to