-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainbot.php
74 lines (68 loc) · 2.79 KB
/
mainbot.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chatbot</title>
<link rel="stylesheet" href="css/bot.css">
</head>
<body>
<?php require '_nav1.php' ?>
<div id="container">
<div id="dot1"></div>
<div id="dot2"></div>
<div id="screen">
<div id="header">CHATBOT</div>
<div id="messageDisplaySection">
<!-- bot messages -->
<!-- <div class="chat botMessages">Hello there, how can I help you?</div> -->
<!-- usersMessages -->
<!-- <div id="messagesContainer">
<div class="chat usersMessages">I need your help to build a website.</div>
</div> -->
</div>
<!-- messages input field -->
<div id="userInput">
<input type="text" name="messages" id="messages" autocomplete="OFF" placeholder="Type Your Message Here." required>
<input type="submit" value="Send" id="send" name="send">
</div>
</div>
</div>
<!-- jQuery CDN -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<!-- Jquery Start -->
<script>
$(document).ready(function(){
$("#messages").on("keyup",function(){
if($("#messages").val()){
$("#send").css("display","block");
}else{
$("#send").css("display","none");
}
});
});
// when send button clicked
$("#send").on("click",function(e){
$userMessage = $("#messages").val();
$appendUserMessage = '<div class="chat usersMessages">'+ $userMessage +'</div>';
$("#messageDisplaySection").append($appendUserMessage);
// ajax start
$.ajax({
url: "bot.php",
type: "POST",
// sending data
data: {messageValue: $userMessage},
// response text
success: function(data){
// show response
$appendBotResponse = $appendBotResponse = '<div id="messagesContainer"><a href="musicH.php"><button style="height:auto;width:auto;margin-left: 100px;" class="chat botMessages">'+data+'</button></a></div>';
$("#messageDisplaySection").append($appendBotResponse);
}
});
$("#messages").val("");
$("#send").css("display","none");
});
</script>
</body>
</html>