forked from adithbharadwaj/ethereum-DApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_empl.html
108 lines (81 loc) · 3.05 KB
/
add_empl.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
<!DOCTYPE html>
<html>
<head>
<title>Add Employer</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src = "abi.js"></script>
</head>
<body>
<body style="background: #ddd;">
<h1 style="text-align: center;">Details Form</h1>
<p style="padding-bottom: 50px;"></p>
<form id="contact-form" method="post" role="form">
<div class="messages"></div>
<div class="col-lg-12" >
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="form_name">Employer Name *</label>
<input id="nam" type="text" name="nam" class="form-control" placeholder="Please enter your name *" required="required" data-error="Firstname is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="form_name">Employer Address *</label>
<input id="address" type="text" name="address" class="form-control" required="required" data-error="Address is required.">
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<p style="padding-top: 20px;"></p>
<div class="row">
<div class="col-md-12">
<input type="submit" class="btn btn-success" id="submit" >
</div>
</div>
</div>
<script type="text/javascript">
var webObject;
window.addEventListener('load', function() {
if (typeof web3 !== 'undefined') {
//Use Mist/MetaMask's provider
web3 = new Web3(web3.currentProvider);
} else {
alert("Install Metamask");
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
alert("Using HTTP");
}
web3.eth.defaultAccount = web3.eth.accounts[0];
var mbst = web3.eth.contract(abi);
webObject = mbst.at(address);
});
var Name = "";
var Address = "";
$('#contact-form').submit(function () {
recieve();
return false;
});
function recieve(){
Name = document.getElementById('nam').value;
Address = document.getElementById('address').value;
try {
webObject.createEmp(String(Name),
String(Address),
{ from: web3.eth.defaultAccount, gas: 3000000, value: web3.toWei(0.01)},
function(err, res) {
if(!err){
alert("Employer created");
}
else
alert(err);
})
//.send({ from: web3.defaultAccount, value: web3.utils.toWei("0.01")})
} catch (e) { alert(e); }
}
</script>
</body>