登录 | 注册 | FAQ
Anonymous

strange form redirecting ?!

+ 发表回复

7 篇帖子 分页: 1 / 1


strange form redirecting ?!

freeAngel » 周五 10月 29, 2010 2:43 pm

Hi guys,

i have a problem with html form

代码: 全选
       <form  action="?history"  method="GET">
           <select name="year" onchange="this.form.submit()">
               <option value="2010">2010</option>
               <option value="2009">2009</option>
           </select>
       </form>


ok, after you select 2009 item - it should go to "localhost/?history&year=2009", but its going to "localhost/?year=2009"

its weird. newer happen to me before. i tested it on ie8, firefox , chrome. and all with same result.

do anyone know what can be a problem?

thx. for all answers
头像

freeAngel

  • 帖子: 2
  • 注册: 周五 10月 29, 2010 2:18 pm

Re: strange form redirecting ?!

lacroixz » 周五 10月 29, 2010 4:09 pm

Maybe in here!
代码: 全选
<form action="?history" method="GET">


The question mark might be the problem, or maybe the use of capital letters like "GET".
Otherwise I've got no idea, goodluck! :)
头像

lacroixz

  • 帖子: 74
  • 注册: 周三 10月 27, 2010 9:26 pm

Re: strange form redirecting ?!

freeAngel » 周五 10月 29, 2010 6:54 pm

haha,

i created 2 html files index.html and index2.html

index.html
代码: 全选
<html>
<body>

  <form  action="index2.html?history"  method="get">
               
  <select name="year">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>
<input type="submit" value="submit">
</form>
</body>
</html>



index2.html
代码: 全选
<html>
<body>
Hello world.
</body>
</html>


ok when i choose "volvo" /or other item/ then i submit form in index.html it should redirect to "localhost/index2.html?history&year=volvo" right? but it redirects me to "localhost/index2.html?year=volvo" and thats strange.

---------
ok it works with method="post" but dont works with method="get"

anyone know what can be the problem?
头像

freeAngel

  • 帖子: 2
  • 注册: 周五 10月 29, 2010 2:18 pm

Re: strange form redirecting ?!

lacroixz » 周六 10月 30, 2010 12:26 pm

freeAngel 写道:haha,

i created 2 html files index.html and index2.html

index.html
代码: 全选
<html>
<body>

  <form  action="index2.html?history"  method="get">
               
  <select name="year">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>
<input type="submit" value="submit">
</form>
</body>
</html>



index2.html
代码: 全选
<html>
<body>
Hello world.
</body>
</html>


ok when i choose "volvo" /or other item/ then i submit form in index.html it should redirect to "localhost/index2.html?history&year=volvo" right? but it redirects me to "localhost/index2.html?year=volvo" and thats strange.

---------
ok it works with method="post" but dont works with method="get"

anyone know what can be the problem?


Maybe because u've got ->

代码: 全选

<select name="year">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>


I mean '<select name="year">
头像

lacroixz

  • 帖子: 74
  • 注册: 周三 10月 27, 2010 9:26 pm

Re: strange form redirecting ?!

HTML.net » 周日 10月 31, 2010 11:11 am

Did you find a solution? Otherwise, try this:

代码: 全选
<select onchange="window.location=this.value">
   <option value="index2.html?history&year=volvo">Volvo</option>
   <option value="index2.html?history&year=saab">Saab</option>
   <option value="index2.html?history&year=mercedes">Mercedes</option>
   <option value="index2.html?history&year=audi">Audi</option>
</select>


- Andreas, HTML.net
头像

HTML.net
Site Admin

  • 帖子: 1194
  • 注册: 周六 9月 11, 2010 11:24 am
--
Show some love for HTML.net on Twitter, Facebook and Google: Use the buttons on top of all pages.

Re: strange form redirecting ?!

saeednri2 » 周六 9月 03, 2016 9:22 am

use of capital letters! I think!
طراحی سایت
头像

saeednri2

  • 帖子: 4
  • 注册: 周六 9月 03, 2016 9:19 am

Re: strange form redirecting ?!

dejavu » 周三 9月 28, 2016 3:41 pm

Did you find the solution?
头像

dejavu

  • 帖子: 7
  • 注册: 周三 9月 28, 2016 2:10 pm


+ 发表回复

分页: 1 / 1