Click to See Complete Forum and Search --> : Create an URL like the form.submit does


Damkenso
07-28-2003, 09:08 AM
Hi !
I need some help to do a little thing in JavaScript !
My problem is quite simple: I want to compute an URL with the parameters like the one computed by the browser when a form (in GET mode) is submitted. Of course I do not want to submit the form :)
I could perform a DOM exploration, but it seems to be a little awkward ! :)

Thanks for any response !

Damkenso

Khalid Ali
07-28-2003, 09:14 AM
aaaanh

:confused: :confused: :confused:

:D

Nevermore
07-28-2003, 09:16 AM
The process is called escaping. Here is some code to help you on your way.

<input type="text" id="toescape"/><input type="button" value="Escape" onclick="alert(escape(document.getElementById('toescape').value));"/>

That will alert an escaped version of the text you insert. All you need to do is to make the JavaScript put to gether the fixed and variable parts of the URL and then send the browser to the correct URL.

Damkenso
07-28-2003, 09:46 AM
Thanks cijori for your response, the escaping problem is a part of the whole problem (but it helps:) ... I do not know the html elements that are present in my document (the page is generated). This is why I was talking about DOM exploration. I wonder if there a method to call on a browser object to compute this instead of doing it myself.
Thx,

Damkenso

Nevermore
07-28-2003, 09:50 AM
So what, you want to look through the page for certain features and then create a URL based on them?

Damkenso
07-28-2003, 09:56 AM
Ok, I might not be very clear but the idea is to create exactly the SAME url like I was submitting the form.
I need this to make a call with XMLHttpRequest object to a servlet in order to incrementally refresh my page.
This servlet (which I cannot modify) do its job: ie takes the parameters and produces a response form them.
I hope this is clearer now :)

Nevermore
07-28-2003, 10:05 AM
So just take each value to encode into the URL and format it individually, then jam em together.

Damkenso
07-28-2003, 10:17 AM
Ok, this is what I was thinking. But I was looking for a browser built in way to do that ....

Bye,

Thx for your time