I'm trying to start using Brython in an on-line course. In order to test it I created a simple unit-conversion exercise where a student fills in a speed in mph and gets back the speed in ft/s. Works fine. But I find that any second calculation I add is ignored. Something needs to be zeroed out, or flushed, or reset or something! Any advice would be appreciated. The code for this simple exercise is below (I've not loaded MathJax, so the $ signs)
...you'll see that the first one works fine and the second one, while identical except for changing the names of the function and all variables is simply ignored.
Thanks!
<HTML>
<HEAD>
<META charset="utf-8">
<script type="text/javascript"
src="https://cdn.rawgit.com/brython-dev/brython/3.3.5/www/src/brython.js">
</script>
<script type="text/javascript"
src="https://cdn.rawgit.com/brython- dev/brython/3.3.5/www/src/brython_stdlib.js">
</script>
</HEAD>
<BODY bgcolor="white" onload="brython(1)">
<H1>test</H1>
<!-- silly test example anticipating multiple unit conversions in a row: -->
<!-- This will work if I remove the previous script and form...but won't if it follows -->
<SCRIPT type ="text/python">
import math
from browser import document
@document["vmph"].bind("change")
def gcal(xx):
# get the first element with tag "form" in the document
fh = document.select("form")[0]
vvmph = float(fh.vmph.value)
vvftps = vvmph*1.4666700004
fh.vftps.value = vvftps
</SCRIPT>
<FORM method="" action="">
<p class="ex1">For $v$ mph = <INPUT Type="text" Name="vmph" id="vmph" Value="" Size="10" autocomplete="off"> $\;\;$mph<br>
we get that $v$ ft per second = <INPUT Type="text" Name="vftps" Value="" Size="10">.
</p>
</FORM>
<SCRIPT type ="text/python">
import math
from browser import document
@document["vmph2"].bind("change")
def gcal2(xxx):
# get the first element with tag "form" in the document
fh2 = document.select("form")[0]
vvmph2 = float(fh2.vmph2.value)
vvftps2 = vvmph2*1.4666700004
fh2.vftps2.value = vvftps2
</SCRIPT>
<FORM method="" action="">
<p class="ex1">For $v$ mph = <INPUT Type="text" Name="vmph2" id="vmph2" Value="" Size="10" autocomplete="off"> $\;\;$mph<br>
we get that $v$ ft per second = <INPUT Type="text" Name="vftps2" Value="" Size="10">.
</p>
</FORM>
</BODY>
</HTML>