-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
51 lines (33 loc) · 932 Bytes
/
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
<!DOCTYPE html>
<html>
<head>
<title>HOLA SOY EL INDEX.HTML</title>
</head>
<body>
<div style="text-align: center;"><h1>Socket.Io Node js, Php y Mysql</h1></div>
<form id="form">
<input type="text" id="input">
<button type="submit">Enviar Texto</button>
</form>
<div id="parrafo"></div>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript">
var conexion = io();
var form = document.getElementById('form');
var input = document.getElementById('input');
form.addEventListener('submit', (event) => {
event.preventDefault();
console.log(input.value);
var vtext = input.value;
conexion.emit("mensaje", vtext);
input.value = "";
});
conexion.on("msg", prf)
function prf(data) {
var parrafo = document.getElementById('parrafo');
parrafo.innerHTML += `<p>${data}<br></p>`
console.log(data);
}
</script>
</body>
</html>