Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.40 KB | None | 0 0
  1. <html>
  2. <head>
  3. <link type="text/css"rel="stylesheet" href="stylesheet.css">
  4. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  5. <title> Comment Post </title>
  6. <script>
  7. function validate()
  8. {
  9. var name = document.getElementById("name", "title", "textarea");
  10. var blank_field = false;
  11. if(name.value == "")
  12. {
  13. name.style.backgroundColor = "pink";
  14. blank_field = true;
  15. }
  16. else
  17. {
  18. name.style.backgroundColor = "lightgreen";
  19. }
  20. if(title.value == "")
  21. {
  22. title.style.backgroundColor = "pink";
  23. blank_field = true;
  24. }
  25. else
  26. {
  27. title.style.backgroundColor = "lightgreen";
  28. }
  29. if(textarea.value == "")
  30. {
  31. textarea.style.backgroundColor = "pink";
  32. blank_field = true;
  33. }
  34. else
  35. {
  36. textarea.style.backgroundColor = "lightgreen";
  37. }
  38. var select1 = document.getElementById("select1");
  39. var select2 = document.getElementById("select2");
  40. if(select1.value == "Choose A Color")
  41. {
  42. select1.style.border = "2px solid red";
  43. blank_field = true;
  44. }
  45. else
  46. {
  47. select1.style.border = "none";
  48. }
  49. if(select2.value == "Choose A Color")
  50. {
  51. select2.style.border = "2px solid red";
  52. blank_field = true;
  53. }
  54. else
  55. {
  56. select2.style.border = "none";
  57. }
  58. var icon = document.getElementsByName("icon");
  59. var radiobtns = document.getElementById("radiobtns");
  60. var blank_radio = true;
  61. for(var i = 0; i < icon.length; i++)
  62. {
  63. if(icon[i].checked == true)
  64. {
  65. blank_radio = false;
  66. }
  67. }
  68. if(blank_radio == true)
  69. {
  70. radiobtns.style.border = "2px solid red";
  71. blank_field = true;
  72. }
  73. else
  74. {
  75. radiobtns.style.border = "none";
  76. }
  77. var error = document.getElementById("error");
  78. if(blank_field == true)
  79. {
  80. error.innerHTML = "<h3 style = 'color:red;'>You missed a spot!</h3>";
  81. }
  82. else
  83. {
  84. error.innerHTML = "";
  85.  
  86. }
  87. add();
  88. }
  89. var array = [];
  90. function add()
  91. {
  92. //variables
  93. var name = document.getElementById("name");
  94. var title = document.getElementById("title");
  95. var textarea = document.getElementById("textarea");
  96. var icon = document.getElementsByName("icon");
  97. var select1 = document.getElementById("select1");
  98. var select2 = document.getElementById("select2");
  99. var icon_value;
  100. for(i = 0; i < icon.length; i++)
  101. {
  102. if(icon[i].checked == true)
  103. {
  104. icon_value = icon[i].value;
  105. }
  106. }
  107.  
  108. //all variables and loops go above this
  109. var storage = {name: name.value, title: title.value, comment: textarea.value, icon: icon_value, tcolor: select1.value, bgcolor: select2.value};
  110. array.push(storage);
  111. show();
  112. }//end function add
  113. function show()
  114. {
  115. var display = document.getElementById("display");
  116. var post = "";
  117. for(var i = 0; i < array.length; i++)
  118. {
  119. post += "<div style='background-color:"+array[i].bgcolor+";'>";
  120. post += "<span style='color:"+array[i].tcolor+";'>";
  121. post += "<b>" + array[i].name + "</b><br>";
  122. post += array[i].title + "<br>";
  123. post += array[i].comment + "<br>";
  124. post += "<img src = " + array[i].icon + " class = 'icon' />";
  125. post += "</span>";
  126. post += "</div>";
  127. html += "<input type='checkbox' onclick='removeComment("+i+");'/>";
  128. }
  129. display.innerHTML = post;
  130. }//end function show
  131. function remove(index)
  132. {
  133. show.splice(index, 1);
  134. show();
  135. }
  136. </script>
  137. </head>
  138. <body id = "body">
  139. <div class = "container">
  140. <div class = "row">
  141.  
  142. <div class="col-xs-12 col-sm-4" id="logo">
  143. <img class = "img-responsive" src = "bubble.jpg">
  144. </div>
  145.  
  146. </div>
  147. <div class = "row">
  148.  
  149. <div class = "col-xs-12" id = "menu">
  150. <ul class = "nav nav-tabs">
  151. <li><a href = "http://simplycoding.org">Simply coding</a></li>
  152. <li><a href = "http://google.com">Google</a></li>
  153. <li><a href = "http://gamersvortex.tk">Gamer's Vortex</a></li>
  154. </ul>
  155. </div>
  156.  
  157. </div>
  158. <div class = "row">
  159.  
  160. <div class = "col-xs-12 col-sm-8" id = "comments">COMMENTS
  161. <div class = "col-xs-12 col-sm-4" id = "form">
  162.  
  163. <header id = "header">
  164. LEAVE A COMMENT
  165. <div id = "error"></div>
  166. </header>
  167. <form class = "form-inline">
  168. <label>
  169. Name:
  170. </label>
  171. <input type="text" class="form-control" id="name" placeholder="Enter Name">
  172. <label>
  173. Color:
  174. </label>
  175. <select id = "select1" class = "form-control">
  176. <option>Choose A Color</option>
  177. <option>Red</option>
  178. <option>Blue</option>
  179. <option>Pink</option>
  180. <option>Turquoise</option>
  181. </select>
  182. </form>
  183. <form class = "form-horizontal">
  184. <label class = "control-label">
  185. Title:
  186. </label>
  187. <input type="text" class="form-control" id="title" placeholder="Enter Comment Title">
  188. <label>
  189. Background Color:
  190. </label>
  191. <select id = "select2" class = "form-control">
  192. <option>Choose A Color</option>
  193. <option>Gold</option>
  194. <option>#cc0099</option>
  195. <option>Orange</option>
  196. <option>Purple</option>
  197. </select>
  198. </form>
  199. <form id = "radiobtns" class = "form-inline">
  200. <label class = "control-label">
  201. Icons:
  202. </label>
  203. <input type="radio" name="icon" value = "imoji.png">
  204. <img src="imoji.png" class="icon" />
  205.  
  206. <input type="radio" name="icon" value = "imoji2.png">
  207. <img src="imoji2.png" class="icon" />
  208.  
  209. <input type="radio" name="icon" value = "imoji3.png">
  210. <img src="imoji3.png" class="icon" />
  211.  
  212. <input type="radio" name="icon" value = "imoji4.png">
  213. <img src="imoji4.png" class="icon" />
  214. </form>
  215. <label class = "control-label">
  216. Comment:
  217. </label>
  218. <textarea id = "textarea" class = "form-control" rows = "8"></textarea><br>
  219. <input class = "btn btn-default" type = "button" value = "Submit Comment" onclick = "validate()">
  220.  
  221. </div>
  222. <div id = "display"></div>
  223. </div>
  224.  
  225. </div>
  226. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement