• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hidden input elemnets via POST

 
Sumukh Deshpande
Ranch Hand
Posts: 87
Firefox Browser IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing an issue when I am trying to submit a JSP page .


I will describe in short the scenario so that it would be clear.

The Scenario

I have some input elements made up in a html component:



on JSP page.

The table has many <tr>. These <tr> have been given ids, for e.g. .

Now I am trying to pass a comma separated list of these tr ids to server side code or Servlet.

The comma separated list is formed with looping some logic on submit of JSP or more specifically a form.

The Problem:

When I submit the form sometimes I do not receive the comma separated values mentioned above at server side code.

This happens occasionally. Now when I put some delay through Java Script like setTimeOut() I do not face the issue.

So can anyone please help me guiding on this?

Is Java Script behavior a bit non - sequential sometimes?

Thanks in advance.



 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64615
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like this is more of a JavaScript question than a JSP question.

And no, JavaScript behavior is not "a bit non - sequential sometimes".
 
Sumukh Deshpande
Ranch Hand
Posts: 87
Firefox Browser IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Bear Bibeault it is a Java Script issue.

But I thought someone could help me out here.

One more doubt I had : My form submission is based on a "onclick" event. So is it possible that JavaScript executions is not finished fully but form is submitted?

Why I am asking is this because I get the comma separated list empty at server side. And most importantly there is no Java Script error too.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64615
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the HTML forum.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What JavaScript code is executing? Also ids can not be numbers.

Eric
 
Sumukh Deshpande
Ranch Hand
Posts: 87
Firefox Browser IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Pascarello,

The JavaScript executing:



The loop above which you see is not completed till the form gets submitted.

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If data is an array, there is no need to loop, plus your way gives you a trailing comma at the end.



Looking at the code you posted, it should not have any timing issues.

Only way I would see a timing issue is if the button was a type="submit" or if it was a <button>.

Eric
 
Sumukh Deshpande
Ranch Hand
Posts: 87
Firefox Browser IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Pascarello,

Only way I would see a timing issue is if the button was a type="submit" or if it was a <button>.


So in any case is it possible that the Java Script code did not completed fully but the form got submitted?

What I mean is whether Java Script would behave asynchronously?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64615
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, JavaScript has asynchronous aspects: events, timers, Ajax, etc.

But, if you mean "will statements execute out of order", then no.
 
Sumukh Deshpande
Ranch Hand
Posts: 87
Firefox Browser IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for all your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic