| Author |
Hidden input elemnets via POST
|
Sumukh Deshpande
Ranch Hand
Joined: Feb 17, 2008
Posts: 87
|
|
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
Joined: Jan 10, 2002
Posts: 56202
|
|
Sounds like this is more of a JavaScript question than a JSP question.
And no, JavaScript behavior is not "a bit non - sequential sometimes".
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Sumukh Deshpande
Ranch Hand
Joined: Feb 17, 2008
Posts: 87
|
|
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
Joined: Jan 10, 2002
Posts: 56202
|
|
|
Moved to the HTML forum.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
What JavaScript code is executing? Also ids can not be numbers.
Eric
|
 |
Sumukh Deshpande
Ranch Hand
Joined: Feb 17, 2008
Posts: 87
|
|
Eric Pascarello,
The JavaScript executing:
The loop above which you see is not completed till the form gets submitted.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
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
Joined: Feb 17, 2008
Posts: 87
|
|
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
Joined: Jan 10, 2002
Posts: 56202
|
|
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
Joined: Feb 17, 2008
Posts: 87
|
|
|
Thanks a lot for all your help.
|
 |
 |
|
|
subject: Hidden input elemnets via POST
|
|
|