I've been working on a college project for which I need to use dates and enter them in the database (the built-in one in the Chrome browser). To be specific, I'll be taking a date from the user and enter it in the database.
The HTML code goes like this:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
</head>
<body>
<input type="date" id="dt">
<input type="button" id="submit" value="INSERT DATE">
</body>
<script type="text/javascript" src="js/index.js"></script>
</html>
And the JavaScript:
var db = openDatabase("Dates", "1.0", "Test Dates", 200000);
var createStatement = "CREATE TABLE IF NOT EXISTS Date (sampledate DATE)";
var insertStatement = "INSERT INTO Date (sampledate) VALUES (?)";
db.transaction(function(tx) {
tx.executeSql(createStatement, []);
});
$(document).ready(function() {
$("body").fadeIn(2000);
$("#submit").click(insertdate);
});
function insertdate() {
var datetemp = $("#dt");
db.transaction(function(tx) {
tx.executeSql(insertStatement, [datetemp])
})
alert("SUCCESS");
}
This is what I get in the database:
So it'd be really great if I get some help!
