Under construction ...

Question: How can I make "Hitting Enter" mean "Submit Data"? I am using a form in my html to send to or get from my GeoGebra file. But if a student hits Enter, not only is this data not submitted, the page reloads.

Example: I want to send a new function definition for f(x) to GeoGebra.
  • Each input field must have its own form.
  • Use the following format:
<form onsubmit="if (this.submitted){return true;} else {ggbApplet.evalCommand('f(x)=' + fx.value); return false;}">
        <i>f(x) =</i>
        <i><input size="50" name="fx" align="middle" value="2" type="text">
  • The input field must have a name: name="fx" where fx must be different for each form.

The first part of the onsubmit: if (this.submitted){return true;} stops the browser from reloading the page when the user hits Enter in this form.
The second part of the onsubmit: else {ggbApplet.evalCommand('f(x)=' + fx.value); return false;} tells the browser what to do when the user hits Enter in this form. Here we want the browser to activate the GeoGebra JavaScript Interface function: evalCommand() - that is, send the command: f(x)= our input to GeoGebra thus redefining f(x).

Related Topics

 Up one level

geogebra help fraction reduce coefficient

Page last modified on September 26, 2008, at 02:53 AM