0

How do I make the button go to the google page when I write 1 in the textbox?

<!DOCTYPE html> <html> <head> <script> var x; function tab(x){ switch (x) { case 1: window.open("www.google.com"); break; case 7: break; case 15: break; case 23: break; } } </script> <title>Student Service Center</title> <meta charset="utf-8" /> <style> body{ background-image:url("42205535-laptop-student-boy-.jpg"); background-size: cover; background-repeat: no-repeat; } .foot{ position:absolute; bottom:0; } .head{ top:0; position:absolute; } .organizer1{ top:100px; position:absolute; } .organizer2{ top:150px; position:absolute; } </style> </head> <body> <div class="head" style="Background-color:#90AFC5;"> <h1><font color=#2A3132 face="Georgia" size="+3">Student Service Center</font></h1> </div> <div class="organizer1"> Section<b>:</b><input name="table" type="text"/> <button onclick="tab(table.value)">Submit</button> </div> <p class="organizer2"><a href="ZerOne.htm">ZerOne</a>||<a href="CiS.htm">CiS</a></p> <div style="background-color:gray;"><h1 class="foot"><font size="5">FCIS</font></h1></div> </body> </html>

7th Dec 2018, 12:39 PM
Bahaa Elboraey
Bahaa Elboraey - avatar
1 ответ
+ 4
// <body> <input type="text" id="put" onkeyup="go()"> </body> <script> function go(){ var out=document.getElementById("put").value; if(out == 1){ window.location ='https://www.google.com'; }else{ alert("wrong input"); } } </script>
7th Dec 2018, 7:17 PM
Sudarshan Rai
Sudarshan Rai - avatar