我试图让我的代码保存表单的答案
<!DOCTYPE html>
<html>
<head>
<title>Homework 2b</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<h2>Please enter your information</h2>
<form id="myForm" role="form">
<div class="form-group">
<label for="InputName">Your Name</label>
<input type="text" class="form-control" id="inputName" placeholder="Name">
</div>
<div class="form-group">
<label for="InputEmail">Email Address</label>
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
<div class="form-group">
<label for="InputBook">Favorite Movie</label>
<input type="text" class="form-control" id="inputMovie" placeholder="Favorite Movie">
</div>
<button id="save" class="btn btn-default">Save</button>
</form>
<hr>
</div>
<div class="clearfix"></div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<h2>Dataset</h2>
</div>
</div>
<script src="Datainput.js"></script>
</body>
</html>
,javascript就是
var save = document.getElementById("save");
save.onclick = function(){
var Name = document.getElementById("inputName").value;
var Email = document.getElementById("inputEmail").value;
var Movie = document.getElementById("inputMovie").value;
var Form1 = new Form(Name, Email, Movie);
};
function Form(Name, Email, Movie){
this.Name = Name;
this.Email = Email;
this.Movie = Movie;
console.log(Name);
console.log(Email);
console.log(Movie);
};
Form.prototype.Name = '';
Form.prototype.Email = '';
Form.prototype.Movie = '';
我不知道为什么,但它就好像页面上没有javascript,虽然我已经确认它确实是通过firebug加载的,但是当我点击保存时没有任何反应。 任何人都能给我一些关于我应该从这里做些什么的帮助,因为我意识到我需要别的东西但是想知道到目前为止我做错了什么