Advertisement
Guest User

edwardpulubi

a guest
Jun 28th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. <html>
  2. <head>
  3.  
  4. <style>
  5. body{
  6. width:100%;
  7. height:100%;
  8. background-color:#eee;
  9. margin:0px;
  10. }
  11.  
  12. #container{
  13. position:relative;
  14. background-color:white;
  15. width:100%;
  16. height:70%;
  17. margin-bottom:50px;
  18. margin-top:140px;
  19. margin-left:0px;
  20. }
  21.  
  22.  
  23. #top_container{
  24. position:absolute;
  25. margin-top:0px;
  26. width:100%;
  27. height:100px;
  28. background-color:blue;
  29.  
  30. }
  31.  
  32. #currency{
  33. width:100px;
  34. height:100%;
  35. margin-right:10px;
  36. background-color:green;
  37. position:absolute;
  38. margin-left:5px;
  39.  
  40. }
  41.  
  42. #input_amount{
  43. width:100px;
  44. height:100%;
  45. background-color:green;
  46. position:absolute;
  47. margin-left:120px;
  48.  
  49. }
  50.  
  51. #amount_cont{
  52. width:99px;
  53. }
  54.  
  55. #left_button1{
  56. position:absolute;
  57. right:0px;
  58. }
  59.  
  60. #left_button2{
  61. position:absolute;
  62. right:50px;
  63. }
  64.  
  65. #table_container{
  66. position:absolute;
  67. width:100%;
  68. margin-top:95px;
  69.  
  70. }
  71. </style>
  72.  
  73. </head>
  74.  
  75. <body>
  76. <div id="container">
  77. <div id="top_container">
  78. <div id="currency">
  79. <div id="currency_drop">
  80. <select id="dropdown">
  81. <option value="EU"> EUROPE</option>
  82. <option value="Yuan"> Yuan</option>
  83. <option value="US"> US Dollar</option>
  84. <select>
  85. </div>
  86. </div>
  87. <div id="input_amount">
  88. <input type="text" name="amount" id="amount_cont">
  89. </div>
  90.  
  91. <div id="left_button1">
  92. <button type="button" id="add">add</button>
  93. </div>
  94.  
  95.  
  96.  
  97. <div id="left_button2">
  98. <button type="button" id="get_total">get total</button>
  99. </div>
  100.  
  101.  
  102. </div>
  103. <div id="table_container">
  104. <div>
  105. <table>
  106. <thead>
  107. <th> Amount</th>
  108. <th> Currency </th>
  109. <th> Conversion </th>
  110. </thead>
  111. <tbody id="convert-tbody"></tbody>
  112. <table>
  113. </div>
  114.  
  115.  
  116. </div>
  117.  
  118. </body>
  119.  
  120. <script>
  121.  
  122. var USD = 45, EU = 52, YU = 7, computed = 0;
  123.  
  124. document.onclick
  125. function getValues(input, currency){
  126.  
  127. if(currency == 'US')
  128. {
  129. computed = input * USD;
  130. }
  131.  
  132. if(currency == 'EU')
  133. {
  134. computed = input * EU;
  135. }
  136.  
  137. if(currency == 'Yuan')
  138. {
  139. computed = input * YU;
  140. }
  141.  
  142. return computed;
  143. }
  144.  
  145. //
  146. var elements=[];
  147. var ScoreObject = function(amount, currency,conversion){
  148. this.amount = amount;
  149. this.currency = currency;
  150. this.conversion = conversion
  151.  
  152. };
  153.  
  154. document.getElementById("add").onclick = function(){
  155.  
  156. var amount = document.getElementById("amount_cont").value;
  157. var currency = document.getElementById("dropdown").value;
  158. var conversion = 0;
  159.  
  160.  
  161. if(currency == 'US')
  162. {
  163. conversion = amount * USD;
  164. }
  165.  
  166. if(currency == 'EU')
  167. {
  168. conversion = amount * EU;
  169. }
  170.  
  171. if(currency == 'Yuan')
  172. {
  173. conversion = amount * YU;
  174. }
  175.  
  176. var newScoreObject = new ScoreObject(amount,currency,conversion);
  177.  
  178. elements.push(newScoreObject);
  179. populateTable();
  180. console.log(document.getElementById("amount_cont").value);
  181. }
  182.  
  183. function populateTable(){
  184. var tempTr = "";
  185. for(var i=0; i<elements.length;i++){
  186. tempTr += "<tr>";
  187. tempTr += "<td>" + elements[i].amount + "</td>"
  188. tempTr += "<td>" + elements[i].currency + "</td>"
  189. tempTr += "<td>" + elements[i].conversion + "</td>"
  190. tempTr += "</tr>";
  191. }
  192.  
  193. document.getElementById("convert-tbody").innerHTML = tempTr;
  194. }
  195.  
  196. </script>
  197.  
  198. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement