Paul Clapham wrote:You're asking a question about JavaScript, but the code you posted is Java code. It does generate JavaScript code, but now it's unclear whether you're asking about the generated Javascript or the posted Java.
And saying "the code runs in a loop" just adds to the confusion. Is it the Java code or the JavaScript code which runs in a loop?
And asking about the JavaScript which is "right after this textbox" is confusing too. What does "right after" even mean?
I'd suggest you start again. Try to clarify whether you are asking about the act of generating the JavaScript code, or whether you are asking about something which happens when you run that code.
Mo Alexwainy wrote:This is a snipet from my servlet.
There is a loop that generates a percentage value.
Mo Alexwainy wrote:This is a snipet from my servlet.
There is a loop that generates a percentage value.
LOOP STARTS
The input textbox stores the percentage value.
This is done successfully.
Right after the text box, i have called a js where it gets the percentage value from the textbox.
LOOP ENDS.
Ron McLeod wrote:
Mo Alexwainy wrote:This is a snipet from my servlet.
There is a loop that generates a percentage value.
The code that you have posted will generate something that looks like this:
Bear Bibeault wrote:Pay attention to what Paul posted. The JavaScript code does not -- I repeat does not -- execute in line with the Java code. It is run much later in the browser on the user's machine.
Please read this article -- even though it talks about JSP (why aren't you using JSP?) the same is true for HTML code emitted by a servlet.
Mo Alexwainy wrote:
Bear Bibeault wrote:Pay attention to what Paul posted. The JavaScript code does not -- I repeat does not -- execute in line with the Java code. It is run much later in the browser on the user's machine.
Please read this article -- even though it talks about JSP (why aren't you using JSP?) the same is true for HTML code emitted by a servlet.
Thanks. But why does the alert within this js runs at the same time the loop is executed?
Doesnt this mean that the js runs every time the loop circulates?
Also, the below js runs anytime in my servlet whenever i execute it. It does not run at anytime later on.
out.println("<script type=\"text/javascript\">");
out.println("document.getElementById('myBody').innerHTML = '';");
out.flush();
Mo Alexwainy wrote:
Thanks. But why does the alert within this js runs at the same time the loop is executed?
Mo Alexwainy wrote:Also, the below js runs anytime in my servlet whenever i execute it. It does not run at anytime later on.
out.println("<script type=\"text/javascript\">");
out.println("document.getElementById('myBody').innerHTML = '';");
out.flush();
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|