Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta charset="utf-8" />
  6. <title></title>
  7. </head>
  8. <body>
  9. <fieldset>
  10. <legend></legend>
  11. <form id="frm">
  12. Enter Country:<input type="text" value="" /> <br /> <br />
  13. Enter City:<input type="text" value="" /> <br /> <br />
  14. Choose car brand:
  15. BMW:<input type="radio" name="gender" value="BMW" checked>
  16. Audi:<input type="radio" name="gender" value="Audi">
  17. <br>
  18. Choose car properties: <br>
  19. Horsepower:<select name="carlist" id="hp">
  20. <option value="100hp">100hp</option>
  21. <option value="150hp">150hp</option>
  22. <option value="200hp">200hp</option>
  23. <option value="250hp">250hp</option>
  24. </select>
  25. <br>
  26. Year:<select name="carlist" id="year">
  27. <option value="2001">2001</option>
  28. <option value="2002">2002</option>
  29. <option value="2003">2003</option>
  30. <option value="2004">2004</option>
  31. </select>
  32. <br>
  33. transmission:
  34. Automatic:<input type="checkbox" name="transm" value="Automatic">
  35. Manual:<input type="checkbox" name="transm" value="Manual">
  36.  
  37.  
  38. <br>
  39.  
  40. <input type="button" value="Send data" onclick="getDataAndShow()">
  41. </form>
  42. </fieldset>
  43. <p id="demo"></p>
  44.  
  45. <script>
  46. var a, b, c, d, e, h;
  47. var form = document.getElementById("frm");
  48.  
  49. function Car(country, city, brand, horse, year,transm) {
  50. this.country = country;
  51. this.city = city;
  52. this.brand = brand;
  53. this.horse = horse;
  54. this.year = year;
  55. this.transm = transm;
  56. }
  57. function getDataAndShow() {
  58. var year = document.getElementById("year").value;
  59. var hp = document.getElementById("hp").value;
  60. a = form.elements[0].value;
  61. b = form.elements[1].value;
  62. c = carbrand();
  63. d = hp;
  64. e = year;
  65. h = transmi();
  66. var Car1 = new Car(a,b,c,d,e,h);
  67. showData(Car1);
  68. }
  69. function showData(person) {
  70. var item;
  71. var text = "";
  72. for (item in person) {
  73. text += person[item] + "<br/>";
  74.  
  75. }
  76. document.getElementById("demo").innerHTML = text;
  77. }
  78. function carbrand() {
  79.  
  80. if (form.elements[2].checked) {
  81. return form.elements[2].value;
  82. }
  83. else {
  84. return form.elements[3].value;
  85. }
  86. }
  87. function transmi() {
  88. if (form.elements[6].checked) {
  89. return form.elements[6].value;
  90. }
  91. else {
  92. return form.elements[7].value;
  93. }
  94. }
  95.  
  96. </script>
  97. </body>
  98. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement