Kan dit eenvoudiger?
Code (php)
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
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
<button id="send_1">Buy 1 day</button>
<button id="send_30">Buy 30 days</button>
<button id="send_100000">Buy Lifetime</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"
integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
$("#send_1").click(function () {
console.log("click");
hive_keychain.requestCustomJson(
null, 'sm_token_transfer', 'active', '{"to":"eclipsi","qty":95,"token":"DEC","type":"withdraw","app":"splinterviewer"}', '1 day',
function (response) {
console.log(response);
console.log(response.data.username);
console.log(response.result.id);
$.post("purchase.php", { name : response.data.username, days : 1 });
}
);
});
$("#send_30").click(function () {
console.log("click");
hive_keychain.requestCustomJson(
null, 'sm_token_transfer', 'active', '{"to":"eclipsi","qty":1195,"token":"DEC","type":"withdraw","app":"splinterviewer"}', '30 days.',
function (response) {
console.log(response);
console.log(response.data.username);
console.log(response.result.id);
$.post("purchase.php", { name : response.data.username, days : 30 });
}
);
});
$("#send_100000").click(function () {
console.log("click");
hive_keychain.requestCustomJson(
null, 'sm_token_transfer', 'active', '{"to":"eclipsi","qty":26995,"token":"DEC","type":"withdraw","app":"splinterviewer"}', 'Lifetime',
function (response) {
console.log(response);
console.log(response.data.username);
console.log(response.result.id);
$.post("purchase.php", { name : response.data.username, days : 100000 });
}
);
});
</script>
</body>
</html>
<button id="send_30">Buy 30 days</button>
<button id="send_100000">Buy Lifetime</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"
integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
$("#send_1").click(function () {
console.log("click");
hive_keychain.requestCustomJson(
null, 'sm_token_transfer', 'active', '{"to":"eclipsi","qty":95,"token":"DEC","type":"withdraw","app":"splinterviewer"}', '1 day',
function (response) {
console.log(response);
console.log(response.data.username);
console.log(response.result.id);
$.post("purchase.php", { name : response.data.username, days : 1 });
}
);
});
$("#send_30").click(function () {
console.log("click");
hive_keychain.requestCustomJson(
null, 'sm_token_transfer', 'active', '{"to":"eclipsi","qty":1195,"token":"DEC","type":"withdraw","app":"splinterviewer"}', '30 days.',
function (response) {
console.log(response);
console.log(response.data.username);
console.log(response.result.id);
$.post("purchase.php", { name : response.data.username, days : 30 });
}
);
});
$("#send_100000").click(function () {
console.log("click");
hive_keychain.requestCustomJson(
null, 'sm_token_transfer', 'active', '{"to":"eclipsi","qty":26995,"token":"DEC","type":"withdraw","app":"splinterviewer"}', 'Lifetime',
function (response) {
console.log(response);
console.log(response.data.username);
console.log(response.result.id);
$.post("purchase.php", { name : response.data.username, days : 100000 });
}
);
});
</script>
</body>
</html>
Gebruik functies.
Code (php)
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
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
<button id="send_1" onclick="clickbtn( this.id )">Buy 1 day</button>
<button id="send_30" onclick="clickbtn( this.id )">Buy 30 days</button>
<button id="send_100000" onclick="clickbtn( this.id )">Buy Lifetime</button>
<p id="result"></p>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
var obj = {
'send_1': {
'qty': 95,
'days': '1 day'
},
'send_30': {
'qty': 1195,
'days': '30 days'
},
'send_100000': {
'qty': 26995,
'days': 'Lifetime'
}
};
function clickbtn( id ) {
document.getElementById('result').innerHTML = 'Aantal = ' + obj[id]['qty'] + '<br />' + 'Dagen = ' + obj[id]['days'];
// verder verwerken
}
</script>
<button id="send_30" onclick="clickbtn( this.id )">Buy 30 days</button>
<button id="send_100000" onclick="clickbtn( this.id )">Buy Lifetime</button>
<p id="result"></p>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
var obj = {
'send_1': {
'qty': 95,
'days': '1 day'
},
'send_30': {
'qty': 1195,
'days': '30 days'
},
'send_100000': {
'qty': 26995,
'days': 'Lifetime'
}
};
function clickbtn( id ) {
document.getElementById('result').innerHTML = 'Aantal = ' + obj[id]['qty'] + '<br />' + 'Dagen = ' + obj[id]['days'];
// verder verwerken
}
</script>
Bron van inspiratie :
https://stackoverflow.com/questions/4329092/multi-dimensional-associative-arrays-in-javascript
Gewijzigd op 28/09/2021 19:23:22 door Adoptive Solution