Closed Thread Icon

Topic awaiting preservation: Parsing Form Post with Javascript (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8397" title="Pages that link to Topic awaiting preservation: Parsing Form Post with Javascript (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Parsing Form Post with Javascript <span class="small">(Page 1 of 1)</span>\

 
Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 11-18-2002 22:32

Hello,

Does anyone know how to parse the values posted by a form using JavaScript? I have figured out how to parse the quersytring, but not sure how to get at the form values.

Thanks!
Karl


karl@laketahoegymnasticscamp.com

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-18-2002 23:00

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 11-18-2002 23:26

Oh shoot... I may have not asked my question well.
I'm talking about parsing the form vars after the form has been posted.




karl@laketahoegymnasticscamp.com

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-18-2002 23:31

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 11-19-2002 00:01

Oh, I think what he's saying is when you post a form and then it gets appended to the URL like

...mypage.html?a=b&c=d&this=that

Here's how you can do it:

window.location.search
gets the "?a=b&c=d&this=that"

window.location.search.substr(1)
cuts off the "?" for "a=b&c=d&this=that"

window.location.search.substr(1).split('&')
makes an array ["a=b","c=d","this=that"]

so probably the easiest thing to do is:

pagearguments = new Object();
pageargumentstrings = window.location.search.substr(1).split('&');
for (a=0; a < pageargumentstrings.length; a++)
{
eval("pagearguments." + pageargumentstrings[a]);
}

That has the effect of evaluating the code "pagearguments.a=b", "pagearguments.this=that", etc. So then you can get at them with

alert(pagearguments.this); // says "that"

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 11-19-2002 18:02

I think he's got that method down (I mean retrieving from forms posted with the GET method).

Now I could totally be wrong but I don't think you can retrieve the data submitted via a POST method using Javascript. At least I've never heard of such a thing.



.:[ Never resist a perfect moment ]:.

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 11-19-2002 19:40

Correct,
I need to retrieve the values from a form submitted via a POST.
Is this not possible? I would imagine that you would need to somehow parse the HTTP Header.



karl@laketahoegymnasticscamp.com

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 11-19-2002 19:52

Oh, yeah, you can't do that with javascript. The form variables are sent to the server, but the server doesn't send them back with the response, so the javascript has no way of getting to them.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-20-2002 10:35

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 11-20-2002 18:38

I should describe better what I am trying to do, actually I've asked something similar before, however I was actually passing variables in the querystring so they weren't getting lost on the roundtrip to the server. However, this time around, we are performing a form POST.

All right:
I have a page full of results from a database (so like 50 of them). Each result contains a form button who's onclick event fires off the form on the page, this button is responsible for passing the ID of this record to this JS function. The form actually POSTS to this same page, the page when it receives a form post will rewrite the results on the page, and then for the ID passed will expand the results there.
And the problem is, that the page scrolls back to the top of the page. The solution is, to scroll the page to the relevant record with the id of XXXXX, after the page is rendered (using a named anchor). This I can do if the ID is passed in the querystring no problem, however with the ID passed in the form, its not working.

I was assuming that the form values were hidden in the HTTP Header somewhere. Maybe not.

Bottom Line: I have to make a round trip to the server, and I have to scroll the page after the page is completely rendered.

Thanks people!



karl@laketahoegymnasticscamp.com

« BackwardsOnwards »

Show Forum Drop Down Menu