HTML 按钮 - 动作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18532143/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML button - action?
提问by Kárpáti András
I would like to make a navigate button: http://tulyita.hu/pr2info.php?name=+ PR2name.text
我想做一个导航按钮:http: //tulyita.hu/pr2info.php?name =+ PR2name.text
What i write wrong?
我写错了什么?
Enter your PR2 name: <input type="text" name="PR2name"><br>
<form method="link" action="http://tulyita.hu/pr2info.php?name=" + PR2name><input type="submit" value="Submit"></form>
回答by LuigiEdlCarno
the methodattribute of the form tag can only tag the value of either "get" or "post".
method表单标签的属性只能标记“get”或“post”的值。
See this linkfor explanation.
请参阅此链接以获取解释。
Your code should look like:
您的代码应如下所示:
<form method="get" action="http://tulyita.hu/pr2info.php">
Enter your PR2 name: <input type="text" name="name"><br>
<input type="submit" value="Submit">
</form>
回答by Praveen
You need Javascript.
你需要Javascript.
var val = document.getElementsByTagName('input[type="text"]').value;
Then pass the val to form.
然后通过 val 来形成。
Also you should also check this about methodattribute.
你也应该检查这个关于method属性。
methodattribute <form method=“link” > or <a>? What's the difference?
method属性 <form method=“link” > or <a>? What's the difference?
There is no
method="LINK"value. This will cause the form to fall back to the default method, GET, which is equivalent to an anchor element with a href attribute anyway.
没有
method="LINK"价值。这将导致表单回退到默认方法 GET,它相当于一个带有 href 属性的锚元素。

