alert() Javascript command not working online all the time

jospercomp shared this question 1 year ago
Answered

I am using the alert command several times in a JavaScript code but it is showing me the information only of the last alert that I have in the code. It only occur in online Geogebra version.

This is an example for them to test why this error occurs.

var num=prompt("Entre un valor",5);

alert("El valor almacenado en la variable num fue: "+num);

ggbApplet.evalCommand("num="+num);

var str=prompt("Entre un mensaje: ","Hola Mundo");

alert("El mensaje almacenado en la variable num fue: "+str);

ggbApplet.evalCommand("str=\""+str+"\"");

var list=prompt("Entre un mensaje: ","{1,2,3,4}");

alert("El mensaje almacenado en la variable list fue: "+list);

ggbApplet.evalCommand("list="+list);

Comments (11)

photo
1

Please post your .ggb file

photo
2

That's expected; each call overwrites the previous

photo
1

Is there a command that pauses to see the information contained in the alert before it is rewritten?


For example, system("pause") such as cpp or a sleep function.

photo
2

Is it just for debugging? Try ggbApplet.debug() and look in the console

photo
1

Where do I find the Java console where prints the string is shown?

photo
1

You'll probably need to run GeoGebra from the command line and/or help - about - system information

photo
1

How I run Geogebra from the command line in Windows 10 and Linux Ubuntu?

efc8e4ad570a5f788d9706e488cbcb80

photo
1

In Applet: https://www.geogebra.org/ma... "3. Estimating π using regularly spaced grid of points" I am using in the javascript the alert command:

...q1=i1 % q0; if(q1==0) alert("m="+i1) .

For GG5 is the usual dialog! For GG6 the dialog box does not appear - alert-text appears only for the last value of the loop variable. See the attached image.

photo
1

That's expected; each call overwrites the previous

photo
© 2020 International GeoGebra Institute