JS: why applet reloads after input value?

nidzela shared this question 12 years ago
Answered

i don't catch what's happening to my JS code in this file...


i'm trying to introduce a certain value from the textarea into a parameter called e, inside the applet.

in essence, it goes like this:


    <form name="Entrada" action="" onsubmit="NouValor(Entrada.inputField.value);

    Entrada.inputField.value='';">

    <input type="text" name="inputField" size="3" style="text-align: center; ">

    </form>


    <script>

    function NouValor(Value) {

    var strInput = Math.round(Value * 2000 / document.ggbApplet.getValue("nt"));

    document.ggbApplet.evalCommand('e = ' + strInput);

    return false;

    }

    </script>


after introducing a value into the textarea and pressing return, the applet reloads!!

Comments (2)

photo
1

Hi,


pressing enter submits the form => sends the data via HTTP GET request. Try


    onsubmit="NouValor(Entrada.inputField.value);Entrada.inputField.value='';return false;">


to prevent this.

photo
1

worked perfectly. thanks a lot!!


(sometimes you get a great satisfaction when realising how reasonable a computer behaviour can be)

© 2023 International GeoGebra Institute