Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"finalchatbox"
Bootstrap 3.0.0 Snippet by
saisreereddy
3.0.0
chat
Preview
HTML
CSS
JS
View Full Screen
Fork
Fork this
2.9K
 
0 Fav
Post to Facebook
Tweet this
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div id='bodybox'> <div id='chatborder'> <p id="chatlog5" class="chatlog"> </p> <p id="chatlog4" class="chatlog"> </p> <p id="chatlog3" class="chatlog"> </p> <p id="chatlog2" class="chatlog"> </p> <p id="chatlog1" class="chatlog"> </p> <p id="chatlog0" class="chatlog"> </p> <input type="text" name="chat" id="chatbox" placeholder="Hi there! Type here to talk to me." onfocus="placeHolder()"> </div> <!--<input type="file" id="myFile" multiple size="50" onchange="myFunction()">--> <input type="file" id="file" name="files[]"/> </div>
body { font: 15px arial, sans-serif; background-color: #d9d9d9; padding-top: 15px; padding-bottom: 15px; } #bodybox { margin: auto; max-width: 550px; font: 15px arial, sans-serif; background-color: white; border-style: solid; border-width: 1px; padding-top: 20px; padding-bottom: 25px; padding-right: 25px; padding-left: 25px; box-shadow: 5px 5px 5px grey; border-radius: 15px; } .chatlog { font: 15px arial, sans-serif; } #chatbox { font: 17px arial, sans-serif; height: 22px; width: 100%; }
function placeHolder() { document.getElementById("chatbox").placeholder = ""; } var messages = [], lastUserMessage = "", botMessage = "", botName = 'sree', talking = true; function chatbotResponse() { talking = true; botMessage = "I'm confused"; if (lastUserMessage === 'hi') { botMessage = 'Hello:)!'; } if (lastUserMessage === 'name') { botMessage = 'My name is ' + botName; } } function newEntry() { if (document.getElementById("chatbox").value != "") { lastUserMessage = document.getElementById("chatbox").value; document.getElementById("chatbox").value = ""; messages.push(lastUserMessage); chatbotResponse(); messages.push("<b>" + botName + ":</b> " + botMessage); for (var i = 1; i < 6; i++) { if (messages[messages.length - i]) document.getElementById("chatlog" + i).innerHTML = messages[messages.length - i]; } } } document.onkeypress = keyPress; function keyPress(e) { var x = e || window.event; var key = (x.keyCode || x.which); if (key == 13 || key == 3) { newEntry(); } } /*function fun() { document.getElementById("chatlog0").innerHTML = "Paragraph changed!"; }*/
Related:
See More
Template
Paper Dashboard Pro
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76