|
 |
javascript thread: Submit a form with edited querystring
Message #1 by "Inge Larsson" <inge.larsson@f...> on Tue, 22 May 2001 08:34:06
|
|
It looks like your problem is that you are trying to use Javascript to do
something that HTML will pretty much do for you. Specifically you're
using the GET method to send a form's inputs - this means that the
names/values of all named form items will be appended to the ACTION
attribute to build up a query string type URL, but you're making the
ACTION attribute into a querystring type link too.
I think there are two possible ways forward here:
1. let HTML do most of the work for you and just use JS for the rest, in
your case it looks like you need 3 hidden fields named Account_id, Action
and Amount and use JS to set their values before submitting the form. The
form itself would always have action="../asp/hostfile.asp" and
method="GET" so you could just put this in the HTML. I'm assuming that
you have more than 1 textbox in your form that you want to do this for.
The disadvantage here is that you would also get name/value pairs for all
other named form objects in your querystring, but you could ignore these.
2. instead of submitting a form, build the URL you want including all
querystring variables and set the window.location to this URL.
Phil
> Hi,
>
> I want to submit a form with a guerystring that is made up dynamically.
> My function, that does not work, looks like this:
>
> function actions(textbox) {
> textbox.form.method="GET";
> textbox.form.action="../asp/hostfile.asp?Action=UpdateAmount"
> + "&Account_id=" + textbox.name + "&Amount=" + textbox.value;
> textbox.form.submit();
> }
>
> The function is invoked "onchange" for a textbox in my form.
>
> I want to send a querystring like this (after the question mark):
>
> Action=UpdateAmount&Account_ID=107&Amount=2300
>
> My questions:
>
> 1. Should my function work in general, if the querystring were OK?
> 2. What could be wrong with the querystring?
>
> I would be very grateful for tips on this problem.
>
> Regards.
|
|
 |