examine form data via JS

W

William Gill

I have not worked with JavaScript for several years, so forgive me if I
get some terminology slightly askew, but is there a way to view what the
HTML specification calls the "form data set" used in a GET or the
"post message" prior to transmission to the server?

I know I can read each input.value attribute to see what they contain,
but the browser is "compiling" this information to append to the URI in
a GET, or to populate the post message in a POST. I would like to be
able to examine that formatted data in the client (browser) via JS prior
to submission. Does anyone know if this is contained in an object
somewhere, or does each browser read and encode the data dynamically as
it processes the executing the request?
 
D

David Mark

I have not worked with JavaScript for several years, so forgive me if I
get some terminology slightly askew, but is there a way to view what the
  HTML specification calls the "form data set" used in a GET or the
"post message" prior to transmission to the server?

Only if you serialize it yourself. Search the archive and you will
likely find numerous discussions on this topic.

[snip]
 
W

William Gill

David said:
I have not worked with JavaScript for several years, so forgive me if I
get some terminology slightly askew, but is there a way to view what the
HTML specification calls the "form data set" used in a GET or the
"post message" prior to transmission to the server?

Only if you serialize it yourself. Search the archive and you will
likely find numerous discussions on this topic.

[snip]

I know I can examine each input field and serialize the data myself, but
what I am trying to do (if possible) is see what the browser had done or
intends to do with the data. I can use GET and examine the resulting
URI, but that is a manual process, and I need to do this programatically.

I may have to create something on the server end to see the raw post
message, but this means two separate processes and a lot of manual
intervention.
 
S

SAM

Le 12/14/08 7:08 PM, William Gill a écrit :
what I am trying to do (if possible) is see what the browser had done or
intends to do with the data.
I can use GET and examine the resulting URI, but that is a manual process,

I know no other way to see what my browser sends
and I need to do this programatically.

In JS ? I think it's not possible.

And ... what that for ?

I may have to create something on the server end to see the raw post
message, but this means two separate processes and a lot of manual
intervention.

Not understood the "manual" interventions on a serveur.
It works with cranks?
 
W

William Gill

SAM said:
I know no other way to see what my browser sends
Nor do I. Which is why I asked if someone else might know.
In JS ? I think it's not possible.
You may be right.
Not understood the "manual" interventions on a serveur.
It works with cranks?
No, my servers don't use cranks, but if I have to code a way to capture
the raw data at the server I still don't have it on the client where I
wanted to see it.
 
T

The Natural Philosopher

William said:
David said:
I have not worked with JavaScript for several years, so forgive me if I
get some terminology slightly askew, but is there a way to view what the
HTML specification calls the "form data set" used in a GET or the
"post message" prior to transmission to the server?

Only if you serialize it yourself. Search the archive and you will
likely find numerous discussions on this topic.

[snip]

I know I can examine each input field and serialize the data myself, but
what I am trying to do (if possible) is see what the browser had done or
intends to do with the data. I can use GET and examine the resulting
URI, but that is a manual process, and I need to do this programatically.

the browser doesn't do anything with the data. Just converts it into
name value pairs and sends it.

you can examine it using getElemntsByName[0].value. Assuming there is
only one uiquely named variable.

I may have to create something on the server end to see the raw post
message, but this means two separate processes and a lot of manual
intervention.

Not sure why you want to see the raw post data anyway. Its simply the
form variables and values.
 
S

SAM

Le 12/15/08 1:27 AM, The Natural Philosopher a écrit :
the browser doesn't do anything with the data. Just converts it into
name value pairs and sends it.

Encore une fois : n'importe quoi !

Once more : philosophical babbling nonsense.

There could be a little more than ASCII characters to send.

Not sure why you want to see the raw post data anyway. Its simply the
form variables and values.

... !
Why do you think functions to translate url exist ?
(in JS as in PHP and more)
 
W

William Gill

The said:
the browser doesn't do anything with the data. Just converts it into
name value pairs and sends it.
The browser doesn't do anything with the data. It just does something
with the data to convert it into name value pairs.
you can examine it using getElemntsByName[0].value. Assuming there is
only one uiquely named variable.
I could use document.getElementsByTagName("input");
or better still
document.getElementById("FormID").getElementsByTagName("input");
then iterate through the value properties of each. Which it's looking
like I may have to do, and just forget about seeing the browser's output
of its similar routine.
 
R

RobG

The said:
the browser doesn't do anything with the data. Just converts it into
name value pairs and sends it.

The browser doesn't do anything with the data. It just does something
with the data to convert it into name value pairs.
you can examine it using getElemntsByName[0].value. Assuming there is
only one uiquely named variable.

I could use document.getElementsByTagName("input");
or better still
document.getElementById("FormID").getElementsByTagName("input");

Better would be to use something like (having ensured getElementById
is supported):

var form = document.getElementById("FormID");

if (form) {
var elements = form.elements;
}

if (elements) {
// do stuff with the form controls
}


To get a collection of all the form's elements - you may be using some
that are other than type input. Not all inputs allow user text input.
 
J

Jeff North

| I have not worked with JavaScript for several years, so forgive me if I
| get some terminology slightly askew, but is there a way to view what the
| HTML specification calls the "form data set" used in a GET or the
| "post message" prior to transmission to the server?
|
| I know I can read each input.value attribute to see what they contain,
| but the browser is "compiling" this information to append to the URI in
| a GET, or to populate the post message in a POST. I would like to be
| able to examine that formatted data in the client (browser) via JS prior
| to submission. Does anyone know if this is contained in an object
| somewhere, or does each browser read and encode the data dynamically as
| it processes the executing the request?

If you mean you want to validate your data client-side then you would
need to use something like:

http://www.jeffnorth.com/newsgroup/FormValidate_CB.html

CAVEAT
If there is an error within your javascript then the form will be sent
to the server. The form will act as if javascript was disabled.

HTH
 
W

William Gill

RobG said:
Better would be to use something like (having ensured getElementById
is supported):

var form = document.getElementById("FormID");

if (form) {
var elements = form.elements;
}

if (elements) {
// do stuff with the form controls
}


To get a collection of all the form's elements - you may be using some
that are other than type input. Not all inputs allow user text input.
You are correct, the elements collection is more complete. I forget the
alternative to getElementById (it's been a few years).

BTW do you know of a good down loadable reference that is searchable and
allows me to scan methods to prod my memory (PDF ?). I can't use
functions or methods I have forgotten about.
 
D

David Mark

You are correct, the elements collection is more complete. I forget the
alternative to getElementById (it's been a few years).

In this case, document.forms.
BTW do you know of a good down loadable reference that is searchable and
allows me to scan methods to prod my memory (PDF ?).  I can't use
functions or methods I have forgotten about.

Not that I know of. See the FAQ for a list of online resources.
 
M

Michael Wojcik

William said:
The browser doesn't do anything with the data. It just does something
with the data to convert it into name value pairs.

.... and only for successful controls. Duplicating the query-string
that will be constructed for a GET-submission, or the content-body for
a POST-submission, is significantly more complex than what is dreamt
of in the Natural Philosophy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top