Submit form with javascript external file -
i have login page:
<html> <head> <title>todo supply title</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" type="text/css" href="css/bootstrap.css" media="screen" /> <script src="http://code.jquery.com/jquery.js"></script> <script type="text/javascript" src="js/loader.js"></script> </head> <body> <div id ="header_login"></div> <div id ="fdm_intro"></div> <div id="footer"></div> </body> </html>
and fallowing header:
<html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" type="text/css" href="css/bootstrap.css" media="screen" /> <script type="text/javascript" src="login.js"></script> <script src="login.js"></script> </head> <body> <div id ="header"> <div class="navbar"> <div class="navbar-inner"> <a class="brand" href="#"> flight data monitor</a> <form name="login" action="" method="get" class="navbar-form pull-right"> <input type="text" class="span2" placeholder="username" name="username"> <input type="text" class="span2" placeholder="password" name="password"> <button type="submit" class="btn" onclick="login(this.form);" >entrar</button> </form> </div> </div> </div> </body> </html>
problem: cannot make alert in login.js. seems form not call javascript.... help??
you forget add jquery reference in html page. try code.
<html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" type="text/css" href="css/bootstrap.css" media="screen" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="login.js"></script> </head> <body> <div id ="header"> <div class="navbar"> <div class="navbar-inner"> <a class="brand" href="#"> flight data monitor</a> <form name="login" action="" method="get" class="navbar-form pull-right"> <input type="text" class="span2" placeholder="username" name="username"> <input type="text" class="span2" placeholder="password" name="password"> <button type="submit" class="btn" onclick="login(this.form);" >entrar</button> </form> </div> </div> </div> </body> </html>
login.js:
$(document).ready(function() { alert(); });
Comments
Post a Comment