我正在尝试实现一个功能,用户可以在输入框中输入文本,点击提交后,将跳转到一个包含他们提交的文本的网页。
例如,如果用户在文本框中输入了单词“apple”并点击了提交,他们将被带到http://example.com/link.aspx?username=apple&jump=1的网页,或者如果他们输入了单词“orange”,他们将被带到http://example.com/link.aspx?username=orange&jump=1的网页。
我尝试了以下代码,但没有成功——它不会在提交时将用户发送到任何地方。
例如,如果用户在文本框中输入了单词“apple”并点击了提交,他们将被带到http://example.com/link.aspx?username=apple&jump=1的网页,或者如果他们输入了单词“orange”,他们将被带到http://example.com/link.aspx?username=orange&jump=1的网页。
我尝试了以下代码,但没有成功——它不会在提交时将用户发送到任何地方。
<form method="get">
<input type="text" value="11" id="input">
<button type="button" id="button">Click Me!</button>
</form>
<script>
$(document).ready(function(){
$('#button').click(function(e) {
var inputvalue = $("#input").val();
window.location.replace(" http://www.example.com/page/"+inputvalue);
});
});
</script>