aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes order of retreiving form parameters using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "order of retreiving form parameters using javascript" Watch "order of retreiving form parameters using javascript" New topic
Author

order of retreiving form parameters using javascript

Stu Johns
Ranch Hand

Joined: Aug 11, 2008
Posts: 63
Does anyone know if its possible to loop through the parameters in a html form in the order that they appear on the screen?

thanks

Stu
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
To be sure, aren't you confusing Javascript with JSP (JavaServer Pages)? You normally don't use Javascript to process request parameters. I also don't see how that's possible when you're using POST instead of GET. On the other hand, when using Javascript for this, I would just walk through the DOM tree. Much easier.

At any way, the order of the request parameters is not specified in the HTML specification. It may be dependent on the webbrowser and appserver used. I wouldn't rely on this.

Look for a solution in another direction. What is it that you're trying to process? Tabular data or so? Try using input name suffixes the smart way. Pass a hidden input element in each row denoting the row ID and suffix the name of all other input elements in the same row with that value.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Perhaps you should tell us what you're really trying to accomplish?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
stef li
Greenhorn

Joined: Jan 16, 2006
Posts: 27
i 'm not clear what you really want to do!


This guy is so lazy!!!<br />There is nothing left!
Stu Johns
Ranch Hand

Joined: Aug 11, 2008
Posts: 63
I have form with a bunch of parameters in it,
in this case a start date and an end date,
I have tested the code and it is not guaranteed that the order of the elements will be displayed, I didnt know if there was a way to ensure the order the parameters would be retreived in the loop, (ie the order they are in the html source).
Thanks for your replies, (I am not lazy though!), I could uniquely identify them as suggested above if order cant be guaranteed another way.
Thanks again for your suggestions

Stu.

>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
There is no way to guarantee it.

Eric
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
If you're traversing the HTML DOM tree, then they will guaranteed be in the same order as they appear in the HTML output. That's why I suggested to crawl the HTML DOM.

It was really confusing that you mentioned "parameters" instead of "input values" or something more client-side specific.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: order of retreiving form parameters using javascript
 
Similar Threads
how to retrieve parameters in the exact order?
Sequence of request parameters
getParameterValues order
request.getParameterNames display order
Ensure correct sequence of printing of request parameters ?