2016-06-30 9 views
-3

why a href tag in html does not work inside a form? I am trying to use that for my jsp page transitions, but it really doesn't work.なぜ<a href> tag doesn't work inside a form

here's my code:

<form method="GET" action="Controller"> 
     <input type="submit" value="Search"/> 
     <a href="/Controller?action=add"><input 
     type="button" value="Add"/></a> 
</form> 

what is the problem why it's not working?

+0

リンクはフォームを送信しません。それには、 ''または '

+0

リンクを使用してフォームを送信しようとしていますか? –

+0

このコードは間違っています。あなたはhtmlフォームの基本を理解していますか?あなたの希望する行動は何ですか? – philipp

答えて

0

You can't wrap an anchor in a button, as they both do something when clicked - it's not valid HTML either. Try:

<form method="GET" action="/Controller?action=add"> 
     <input type="submit" value="Search"/> 
     <input type="button" value="Add"/> 
</form> 

See if that works, but don't wrap a button in an anchor :)

Also, see this question for other elements which can't be wrapped in tags Can I nest a <button> element inside an <a> using HTML5?