友好的URL与GET请求表单
我有一个简单的HTML表单:
<form action="test/" method="get" accept-charset="utf-8">
<input type="text" name="first" value="" id="first">
<input type="text" name="second" value="" id="second">
<input type="text" name="third" value="" id="third">
<p><input type="submit" value="Continue →"></p>
</form>
当用户点击提交按钮时,我想得到一个友好的网址,像这样:
www.site.com/test/first/second/third
我该怎么做呢?
2 个回答
2
<input type="text" name="first" value="" id="first">
<input type="text" name="second" value="" id="second">
<input type="text" name="third" value="" id="third">
<p><input type="button" value="Continue →" onclick="submitFriendly();"></p>
<script type="text/javascript">
function submitFriendly() {
window.location.href = window.location.href + document.getElementById('first').value + '/' + document.getElementById('second').value + '/' + document.getElementById('third').value;
}
</script>
这个应该可以用。它并没有检查所有输入框是否都填好了。
3
用户在填写完表单并点击“继续”后会去哪里,取决于你在