Closed anastasiaalt closed 8 years ago
I have a form with a drop down of topics. When I select from the drop down one topic, it fails to enter the document or appear on the page. The content for the post does appear on the page and in the document of the database.
Form https://github.com/anastasiaalt/finalProject/blob/master/views/form.ejs
<div class="ui form segment container"> <form method="POST" action="/posts"> <div class="one field"> <label for="post-content">Content</label> <input type="text" name="post[content]" id="post-content"> </div> <div class="one field"> <label for="post-topic">Topic</label> <input type="hidden" name="post[topic]" id="post-topic"> <select class="ui dropdown"> <option value="Coding">Coding</option> <option value="Relationships">Relationships</option> <option value="Money">Money</option> </select> </div> <div> <input class= "ui blue submit button" type="submit" value="Create"> </div> </form>
Index Page https://github.com/anastasiaalt/finalProject/blob/master/app.js
<div class="ui three column grid"> <div class="column"> <% posts.forEach(function(post){ %> <div class="ui segment"> <p>Message: <%= post.content %></p> <p>Topic: <%= post.topic %></p> </div> <% }) %> </div> </div>
Main.js https://github.com/anastasiaalt/finalProject/blob/master/public/js/main.js
$('select.dropdown') .dropdown() ;
Terminal for my Collection:
> db.posts.find() { "_id" : ObjectId("56a03f15316c6a108777850b"), "content" : "I'm happy" } { "_id" : ObjectId("56a101e7ac8da71844b869e9"), "__v" : 0 } { "_id" : ObjectId("56a269eafe46e52966d6b0dc"), "content" : "i'm less scared", "topic" : "ok", "__v" : 0 } { "_id" : ObjectId("56a279421e02763366441a80"), "content" : "This is hard", "topic" : "Coding", "__v" : 0 } { "_id" : ObjectId("56a3892a1d29204a6b3ae840"), "content" : "Test", "topic" : "", "__v" : 0 } { "_id" : ObjectId("56a38c274a439baf6e189919"), "content" : "Testing again", "topic" : "", "__v" : 0 } { "_id" : ObjectId("56a398fe6ab0f1bf6f3805bc"), "content" : "My boss hates me", "topic" : "", "__v" : 0 } { "_id" : ObjectId("56a399576ab0f1bf6f3805bd"), "content" : "Testing again", "topic" : "", "__v" : 0 } { "_id" : ObjectId("56a39a656ab0f1bf6f3805be"), "content" : "I want more money", "topic" : "", "__v" : 0 } { "_id" : ObjectId("56a39e50a0f4262570a4f690"), "content" : "Testing again", "topic" : "", "__v" : 0 } > ^C
you need a "name" attribute for your select tag. that sets the key in params
I have a form with a drop down of topics. When I select from the drop down one topic, it fails to enter the document or appear on the page. The content for the post does appear on the page and in the document of the database.
Form https://github.com/anastasiaalt/finalProject/blob/master/views/form.ejs
Index Page https://github.com/anastasiaalt/finalProject/blob/master/app.js
Main.js https://github.com/anastasiaalt/finalProject/blob/master/public/js/main.js
Terminal for my Collection: