-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalc.html
87 lines (80 loc) · 2.03 KB
/
Calc.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>ReactJS </title>
<script src="react.js"></script>
<script src="react-dom.js"></script>
<script src="browser.min.js"></script>
<style>
input {
margin : 10px;
}
</style>
</head>
<body>
<script type="text/babel">
var Calculator = React.createClass({
getInitialState : function(){
return {
percentChange : 0
}
},
rangeChange : function(){
var tax = this.refs.rangeTax.value;
this.setState({
percentChange : this.refs.rangeTax.value
});
},
calculate : function(){
var basic = this.refs.txtBasic.value ;
var da = this.refs.txtDa.value ;
var hra = this.refs.txtHra.value ;
var salary = parseInt(basic) + parseInt(hra) + parseInt(da) ;
var tax = this.refs.rangeTax.value;
console.log(this.refs.rangeTax.value);
this.setState({
percentChange : this.refs.rangeTax.value
});
var taxDeduc = ( tax / 100 ) * salary;
this.setState({
salary : (salary - taxDeduc)
})
},
render : function(){
return (<div>
<table>
<tbody>
<tr>
<td><label>Basic : </label></td>
<td><input type="text" ref="txtBasic"/></td>
</tr>
<tr>
<td><label>Da : </label></td>
<td><input type="text" ref="txtDa"/></td>
</tr>
<tr>
<td><label>Hra : </label></td>
<td><input type="text" ref="txtHra"/></td>
</tr>
<tr>
<td><label>Tax : </label></td>
<td>
<input type="range" ref="rangeTax" onChange={this.rangeChange} />
<span ref="spanTax">[Tax {this.state.percentChange} %]</span>
</td>
</tr>
<tr>
<td><input type="button" value="Calculate" onClick={this.calculate}/></td>
<td><div>Salar : {this.state.salary}</div></td>
</tr>
</tbody>
</table>
</div>);
}
});
ReactDOM.render(<Calculator />, document.body);
</script>
<!-- ReactDOM.render(<Content title="Welcome to React" message="Hey You"/>, document.body); -->
</body>
</html>