Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 获取表单中的文本框值_Html_Jsp - Fatal编程技术网

Html 获取表单中的文本框值

Html 获取表单中的文本框值,html,jsp,Html,Jsp,这是我的代码: <form method="get" action="http://google.com#q=<%= request.getParameter("myname") %>" target="_blank"> Enter your name: <input type="text" name="name"><input type="submit"> </form> 输入您的姓名: 我需要获取在文本框中输入的值,

这是我的代码:

<form method="get" action="http://google.com#q=<%= request.getParameter("myname") %>" target="_blank">
    Enter your name: <input type="text" name="name"><input type="submit">

</form>

输入您的姓名:
我需要获取在文本框中输入的值,并将其附加到动作参数中的URL。如何?上述代码为表达式标记返回null。

html:

<form method="get" action="" target="_blank" id="myForm">
    Enter your name: <input type="text" name="name" id="txtName"><input type="submit" id="submit" value="Submit">
</form>
请注意,如果希望重定向发生在同一页面上,请使用
window.location.href=url
而不是
window.open


希望能有所帮助。

你得到了“myname”作为参数,你的输入名在哪里?
name
Ya我改变了它,但它不起作用,朋友。现在,正如@Gal所说的那样尝试了js。工作。谢谢。在OP没有要求的情况下建议jQuery解决方案。
document.getElementById('submit').oncick = function() {
    var val = document.getElementById('txtName').value;
    window.open('http://google.com?q=' + encodeURIComponent(val));
    return false;
}