W3C home > Mailing lists > Public > www-archive@w3.org > June 2007

Re: Ask a question about get action in form

From: Dan Connolly <connolly@w3.org>
Date: Mon, 04 Jun 2007 13:20:19 -0500
To: yangjianxingg@126.com
Cc: www-archive@w3.org
Message-Id: <1180981219.6980.29.camel@pav>

On Sun, 2007-06-03 at 17:53 +0800, yangjianxingg@126.com wrote:
> Hi, professor Dan Connolly.

Hi. I'm not actually a professor...

> I account a problem about the action get in html form. I read the
> rfc2616(Hypertext Transfer Protocol -- HTTP/1.1 ),
>  but I still cannot solve a problem.
> The problem is as following:
> A html file is like this
> <html>
> <head><title>myTitle</title></head>
>           <body>
>                    <form action="login?name=tom" method="get">
>                           <input type="text" id="another" />
>                            <input type="submit" value="Submit" />
>                    </form>
>           </body>
> </html>
> (login in the form action is a servlet.)
> After I submit , I lose parameter name=tom and only get parameter
> another=something .
> The url in the browser is login?another=something, instead
> of  login?name=tom&another=something.
> I read some materials but I still can't understand. Would you help me?

I suggest you put the name=tom in a hidden form field.

<form action="login">
  <input type="hidden" name="name" value="tom" />
...

For reference:

http://www.w3.org/TR/html4/interact/forms.html#hidden-control

http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.1.2.6


> 
-- 
Dan Connolly, W3C http://www.w3.org/People/Connolly/
Received on Monday, 4 June 2007 18:20:16 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:33:10 UTC