Forum Moderators: open

Message Too Old, No Replies

GET forms: querystring in the action attribute is not used

why?

         

tata668

10:22 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



I know this is probably an old question but I have to admit I've never knew why it works that way:


<form method="get" action="test.php?a=1&b=2">
<input type="submit" name="c" value="3" />
</form>

This will call: "test.php?c=3"

Is there a way to add some parameters to the url inside the "action" attribute in a way that they WILL be used?

I'd like the above example to call "test.php?a=1&b=2&c=3"

Why doesn't the form use them?

Dijkgraaf

11:14 pm on Nov 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try
<form method="get" action="test.php" ID="Form">
<input type="hidden" name="a" value="1" ID="a">
<input type="hidden" name="b" value="2" ID="b">
<input type="submit" name="c" value="3" ID="c"/>
</form>

tata668

11:26 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



I know the method you expose works Dijkgraaf, thanks, but I'd like to know why the former method doesn't!

It would be easy for a browser to just append the form's values to the existing querystring, no?

Dijkgraaf

1:02 am on Nov 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably because it would require extra logic to detect that there is allready a parameters in the action and to append further parameters using a & rather than a?.

They probably just took the easy route and truncated from the? on and then add the parameters as per normal.

Not sure if there is a standard around for this, but if there isn't then results could vary between browser and so putting a parameter in the action is not a safe technique to use.