[英]Form redirect on submit not working, why?
我的搜索表单上有以下代码:
<form name="search" method="get" action="www.test.gr" enctype="multipart/form-data"
onsubmit="window.location.href='www.test.gr/search/document.getElementById('location').value';
return false;">
但这是行不通的。 也许document.getElementById
的引号是错误的。 有人可以帮忙吗?
您应该用对象值连接字符串。 在您的情况下, document.getElementById('location').value
语句被解释为字符串的一部分。
<form name="search" method="get" action="www.test.gr" enctype="multipart/form-data" onsubmit="window.location.href = 'www.test.gr/search/' + document.getElementById('location').value; return false;">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.