Advertisement
muzammalsafdar

Untitled

Oct 13th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. <html lang="en"><head><title>bill</title>
  2. <style>
  3. .spin {
  4. display: inline-block;
  5. }
  6. .spin span {
  7. display: inline-block;
  8. width: 20px;
  9. height: 22px;
  10. text-align: center;
  11. padding-top: 2px;
  12. background: #ff0;
  13. border: 1px solid #aaa;
  14. border-radius: 0 4px 4px 0;
  15. cursor: pointer;
  16. }
  17. .spin span:first-child {
  18. border-radius: 4px 0 0 4px;
  19. }
  20. .spin input {
  21. width: 150px;
  22. height: 20px;
  23. text-align: center;
  24. font-weight: bold;
  25. }
  26. </style>
  27. <script>
  28.  
  29. // sir ye code yahan run ni ho raha lakin jb is ko spearte file main
  30. // run krta hon to phir run ho jata ha
  31. // code start
  32.  
  33.  
  34. var spins = document.querySelectorAll(".spin");
  35. console.log(spins);
  36. for (var i = 0 ; i < spins.length ; i++) {
  37. var spin = spins[i];
  38. var span = spin.querySelectorAll(".spn");
  39. var input = spin.querySelectorAll("#numbers")[0];
  40.  
  41. input.onchange = function() { input.value = +input.value || 0; };
  42. span[0].onclick = function() { input.value = Math.max(0, input.value - 1); };
  43. span[1].onclick = function() { input.value -= -1; };
  44. }
  45.  
  46.  
  47. // code end
  48. // ye code counter k liye ha jo yellow color main ha....
  49.  
  50.  
  51.  
  52. // var submitfun = document.getElementById("sub");
  53. // submitfun.addEventListener('click', sub);
  54. function sub(){
  55. event.preventDefault();
  56.  
  57. var first = document.querySelectorAll(".rad1");
  58. var second = document.querySelectorAll(".rad2");
  59. var third = document.querySelectorAll(".rad3");
  60. var fourth = document.querySelectorAll(".rad4");
  61. var chkfirst = document.querySelectorAll(".chk1");
  62. var chksecond = document.querySelectorAll(".chk2");
  63. var chkthird = document.querySelectorAll(".chk3");
  64. var chkfourth = document.querySelectorAll(".chk4");
  65. var radoutput = ''
  66. var chkoutput = ''
  67.  
  68. first.forEach(function(rad){
  69. if(rad.checked){
  70. radoutput += rad.value + " and ";
  71. }
  72. });
  73. second.forEach(function(rad){
  74. if(rad.checked){
  75. radoutput += rad.value + " and ";
  76. }
  77. });
  78. third.forEach(function(rad){
  79. if(rad.checked){
  80. radoutput += rad.value + " and ";
  81. }
  82. });
  83. fourth.forEach(function(rad){
  84. if(rad.checked){
  85. radoutput += rad.vlaue + " ";
  86. }
  87. });
  88. chkfirst.forEach(function(chek){
  89. if(chek.checked){
  90. chkoutput += chek.value + " and ";
  91. }
  92. });
  93. chksecond.forEach(function(chek){
  94. if(chek.checked){
  95. chkoutput += chek.value + " and ";
  96. }
  97. });
  98. chkthird.forEach(function(chek){
  99. if(chek.checked){
  100. chkoutput += chek.value + " and ";
  101. }
  102. });
  103. chkfourth.forEach(function(chek){
  104. if(chek.checked){
  105. chkoutput += chek.value + " ";
  106. }
  107. });
  108. var inptxt = document.getElementsByClassName("inp")[0].value;
  109. var rst = document.getElementsByClassName("result")[0];
  110. rst.innerHTML = radoutput + "<br>";
  111. rst.innerHTML += chkoutput + "<br>";
  112. rst.innerHTML += inptxt + "<br>";
  113.  
  114. }
  115.  
  116.  
  117.  
  118. </script>
  119.  
  120.  
  121.  
  122.  
  123. </head><body>
  124. <div class="main">
  125. <input class="rad1 rad" type="radio" value="sugar free" name="same">sugar free<br><br>
  126. <input class="rad2 rad" type="radio" value="sweet" name="same"> sweet<br><br>
  127. <input class="rad3 rad" type="radio" value="little sugar" name="same"> little sugar<br><br>
  128. <input class="rad4 rad" type="radio" value="stevia" name="same"> stevia<br><br>
  129. <hr>
  130. <input class="chk1 chk" type="checkbox" value="milk" name="milk"> milk<br><br>
  131. <input class="chk2 chk" type="checkbox" value="milk with fat" name="fat"> milk with fat<br><br>
  132. <input class="chk3 chk" type="checkbox" value="milk without fat" name="nofat">milk without fat<br><br>
  133. <input class="chk4 chk" type="checkbox" value="fat 3%" name="fat3"> fat3%<br><br>
  134. <input class="inp" type="text" value="" name="txt" placeholder="input text"><br><br>
  135. <div class="spin">
  136. <span class="spn">&ndash;</span>
  137. <input id="numbers" value="0" />
  138. <span class="spn">+</span>
  139. </div> <br> <br>
  140. <input type="submit" value="submit" onclick="sub();" id="sub" name=""></div>
  141. <div class="result"></div>
  142.  
  143. </body>
  144. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement