Reputation: 235
I have the following code and just cannot find out why doesn't it add the goal to my ForerunnerDB. I did everything as in the example in the ForerunnerDB manual.
Here is my index.html file:
<!DOCTYPE html>
<meta charset="UTF-8">
<html>
<head>
<title>Barebones todo</title>
<script src="./js/dist/fdb-all.min.js" type="text/javascript"></script>
<script src="scrypt.js" type="text/javascript"></script>
</head>
<body>
<form onsubmit="return addGoal();">
Enter goal: <input type="text"id="goalinput">
<input type="submit">
</form>
<button type="button" onclick="retrieve()">Retrieve</button>
<div id="p"></div>
</body>
</html>
Here is my scrypt.js file:
var fdb = new ForerunnerDB();
var db = fdb.db("myDatabaseName");
var goalCollection = db.collection("goal");
function addGoal() {
console.log("addig goal...");
var newgoalname = document.getElementById("goalinput").value;
console.log(newgoalname);
goalCollection.insert({
_id: 3,
name: newgoalname,
order: 99
});
};
function retrieve() {
var findings = goalCollection.find({});
console.log(findings);
//document.getElementById("paragraph").innerHTML = findings;
document.getElementById("p").innerHTML = findings;
}
Upvotes: 0
Views: 101
Reputation: 235
As @Luigi Cerone noted the issue was the space between
<input type="text"id="goalinput">
Upvotes: 1