Re: Ask a question about get action in form

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