
Modificar variable global de php desde javascript
Publicado por NICOLAS GERMAN (1 intervención) el 12/07/2021 18:57:06
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
<?php
$grados = 0;
?>
<html>
<title> APUNTAMIENTO DE ANTENA </title>
<head>
<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>
</head>
<body>
<center><br><hr>
<div class="container">
<h2>Apuntamiento de Antena</h2>
<br>
<h1 id="contador" style="color:red; font-size: 100px;">0</h1>
<br>
<button class="btn btn-primary" id='0' style="width: 150px; font-size: xx-large;"onclick="menos()">< 0° </button>
<button class="btn btn-primary" id='0' style="width: 150px; font-size: xx-large;"onclick="mas()">180°></button>
<br><br>
<button class="btn btn-primary" id='0' style="width: 100px; font-size: xx-large;" onclick="cero()">0</button>
<button class="btn btn-primary" id='90' style="width: 100px; font-size: xx-large;" onclick="noventa()">90</button>
<button class="btn btn-primary" id='180' style="width: 100px; font-size: xx-large;" onclick="cientoochenta()">180</button>
<hr>
</div>
<script>
function cero() {
<?php
global $grados;
$grados = 0;?>
$('#contador').text(<?php echo "$grados"?>);
}
function noventa() {
<?php
global $grados;
$grados = 90;?>
$('#contador').text(<?php echo "$grados"?>);
}
function cientoochenta() {
<?php
global $grados;
$grados = 180;
?>
$('#contador').text(<?php echo "$grados"?>);
}
function menos() {
<?php
global $grados;
$grados = $grados-2;?>
$('#contador').text(<?php echo "$grados"?>);
}
</script>
</html>
Valora esta pregunta


0