In the below Python CGI script, I am using javascript function for changing the picture on click. But apparently it doesn't seems to work. I am following the example from w3 schools js example. So I just want to conform, is it possible to use the javascript inside Python CGI script.
If same example has to be done in Python, what should be the approach.
#!/usr/bin/env python
import cgi
print """print "Content-type: text/html; charset=utf-8
<!DOCTYPE html>
<html>
<body>
<script>
function changeImage()
{
element=document.getElementById('myimage')
if (element.src.match("bulbon"))
{
element.src="../pic_bulboff.gif";
}
else
{
element.src="../pic_bulbon.gif";
}
}
</script>
<img id="myimage" onclick="changeImage()"
src="../pic_bulboff.gif" width="100" height="180">
<p>Click the light bulb to turn on/off the light</p>
</body>
</html>
"""