根据表单输入将用户重定向到目录 [英] Redirect user to directory based on form input
问题描述
我对Web设计的编码方面了解得足够多,以至于我所不知道的东西使他们感到尴尬.我想做的是在报纸上进行各种印刷促销,而不是通过以下方式进行促销:有关更多信息,请访问www.mysite.com/2345.
I know enough about the coding end of web design to be embarrassed by what I don't know. What I want to do is to have various print promotions in newspapers and what not along the lines of: for more information please visit www.mysite.com/2345.
如果访问者未在导航栏中输入完整的URL并最终到达主索引,则我想在此处输入一个文本字段,以便他们可以输入"2345",然后按Enter或Submit,然后将其重定向到www.mysite.com/2345,将在其中加载文件夹的索引页.
If the visitor doesn't enter the entire url in the nav bar and ends up at the main index, I want to have a text field there so they can enter "2345", hit enter or submit, then be redirected to www.mysite.com/2345 wherein the folder's index page will load.
我通常会搜索并查找所需的编码信息,但是我无法找到一种简洁的方法来搜索此特定问题.任何人都可以帮忙解决这个问题,或者向我指出在其他地方寻求帮助的正确方向吗?
I usually search and find the coding info I'm looking for, but I can't figure out a concise way to search this particular problem. Can anyone help with this or point me in the right direction for help elsewhere?
谢谢.
推荐答案
使用JavaScript非常简单,这是一个有效的示例:
Pretty simple with JavaScript, here's a working example:
<form onsubmit="location.href='http://www.mysite.com/' + document.getElementById('myInput').value; return false;">
<input type="text" id="myInput" />
<input type="submit" />
</form>
这篇关于根据表单输入将用户重定向到目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!