Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions forum.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
body {
background-color: rgb(203, 191, 158);
}

.userName {
color: blue;
}
43 changes: 38 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,54 @@
<html>
<head>
<title>Forum</title>
<title>Peyton Place</title>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="forum.css">
</head>
<body>
<div class="row">
<div class="col-md-6 col-md-offset-3">

<div class="page-header">
<h1>Forum</h1>
<h1>Peyton Place</h1>
</div>

<div class="posts">
<div class="row">
<p id="commentSection"></p>
</div>
</div>

<form style="margin-top:30px;" onsubmit="event.preventDefault();">

<div class="form-group-1">

</div>
<div class="form-group">
<input id="name" type="text"
class="form-control"
placeholder="Name"></input>
</div>

<div class="form-group">
<textarea id="message" type="text"
class="form-control"
placeholder="Message"></textarea>
</div>

<button id="submit" class="btn btn-primary">Add Comment</button>
</form>

</div>
</div>

<!-- <div class="row">
<div class="col-md-6 col-md-offset-3">

<div class="posts">
</div>

<form style="margin-top:30px;" onsubmit="event.preventDefault();">
<h3>Add a new post</h3>
<p>Add a new post</p>

<div class="form-group">
<input id="name" type="text"
Expand All @@ -29,12 +62,12 @@ <h3>Add a new post</h3>
placeholder="Message"></textarea>
</div>

<button id="submit" class="btn btn-primary">Post</button>
<button id="submit" class="btn btn-primary">Add Post</button>
</form>

</div>
</div>

-->
<script src="main.js"></script>
</body>
</html>
Expand Down
26 changes: 25 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
// your code here

// create a feature that would allow the user to add a new "post"
// (a message associated with a user's name) to the '.posts' div.


var comment = document.addEventListener('DOMContentLoaded', function () {
var submitCommentButton = document.querySelector('.btn.btn-primary');
var commentSection = document.getElementById('commentSection');
// when button is clicked, add comment to the list of other comments
submitCommentButton.addEventListener('click', function () {
// USe values of the new submitted name and message
var name = document.getElementById('name').value;
var message = document.getElementById('message').value;

var newComment = `<p>${message} - Posted by: <span class="userName">${name}</span></p>`;
commentSection.innerHTML += newComment;
});
});


// submitCommentButton.addEventListener('click', function () {
// // when button is clicked, add comment to list of comemnts above
// console.log(document.getElementById('name'));

// });