-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
109 lines (65 loc) · 2.26 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html>
<head>
<title>Javascript Calculation</title>
</head>
<style>
.sm{
display: inline-block;
margin-bottom: -4px !important;
box-sizing: border-box;
}
</style>
<body>
<h2>Javascript Calculation</h2>
<div>
<label for="blength">Enter Bigger Rectangle Length:</label><br>
<input type="text" id="blength" name="blength"><br>
<label for="bbreadth">Enter Bigger Rectangle Breadth:</label><br>
<input type="text" id="bbreadth" name="bbreadth"><br><br>
<label for="slength">Enter Smaller Rectangle Length:</label><br>
<input type="text" id="slength" name="blength"><br>
<label for="sbreadth">Enter Smaller Rectangle Breadth:</label><br>
<input type="text" id="sbreadth" name="sbreadth"><br><br>
<button type="button" onClick="calculate()">Calculate</button>
</div>
<br/>
<div id="resdiv">
</div>
<div id="vis">
</div>
<script>
function calculate(){
//take values from respective input box and store into variables
var L=parseInt(document.getElementById("blength").value);
var B=parseInt(document.getElementById("bbreadth").value);
var l=parseInt(document.getElementById("slength").value);
var b=parseInt(document.getElementById("sbreadth").value);
// If the dimension of the smaller
// squares is greater than the
// bigger one
if (l>L||(b > B)){
console.log(l+" "+b);
document.getElementById("resdiv").innerHTML="<strong>The Dimension of squares is greater than Bigger One</strong>";
return false;
}
// Return the number of smaller
// rectangles possible
var res= Math.floor(L/l)*Math.floor(B/b);
//putt the value in result div
document.getElementById("resdiv").innerHTML="<strong>There are "+res+" squares(smaller rectangles) of dimension "+l+" × "+b+" can be Fit or Drawn inside a bigger rectangle of dimension "+L+" × "+B+"</strong>";
var visual=document.getElementById("vis");
visual.style.border="0.1px solid black";
visual.style.height=(L*10)+"px";
visual.style.width=(B*10)+"px";
var ll=l*10+"px";
var bb=b*10+"px";
var s="";
for(var i=0;i<res;i++){
s=s+'<div class="sm" style="border:solid black 0.1px;height:'+ll+';width:'+bb+';"></div>';
}
visual.innerHTML=s;
}
</script>
</body>
</html>