【问题标题】:I want to redirect user to a specific page upon a code in input [closed]我想根据输入中的代码将用户重定向到特定页面[关闭]
【发布时间】:2014-05-11 07:56:40
【问题描述】:

我有一个输入:<input type="text" class="redirect"></input>

当用户输入A80G时,我希望他/她重定向到page1.html,当用户输入B6T4时,我希望他/她重定向到page2.html

有人可以给我建议吗?

我最谦卑的感谢。

    -

【问题讨论】:

  • 发布你为实现这一目标所做的努力
  • 您输入的密码错误
  • 哦,我知道,请问有什么问题?
  • 我不知道如何实现这一点!我应该使用哪种语言? php? JavaScript?
  • 例如,我发布的 Javascript。

标签: html validation redirect input


【解决方案1】:
<input class="redirect" onkeydown="if (event.keyCode == 13){if(this.value=='A80G'){window.location.href='page1.html';};if(this.value=='B6T4'){window.location.href='page2.html';}}">

【讨论】:

  • @user3556445 现在?输入文字并按回车键
【解决方案2】:
you can use switch case for this

$value = $_POST['input'];

switch ($value) {
    case 'A80G':
       header('location:page-1.html');
        break;
    case 'B6T4':
        header('location:page-2.html');
        break;
    default:
       header('location:page-1.html');
}

【讨论】:

  • 哦,谢谢,我会试试
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-08-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多