Hey Im building a chatbot, I'm using a simply input text box and button in html, and have a start function. It's php. When I type in the textbook nothing is appealing on screen and button is not working so it's not displaying my text and a reply onscreen. There seems to be an error with the function, its for college so the code was given to me.
This is my first post on a site like this so excuse me if I'm not putting all info in and explaining myself fully.
The html lines are below and below that is part function? Any advice is greatly appreciated..
<input id="talk" type="textarea" class="tb5" name="searchterm" placeholder="Type to talk to me">
<input id="chat" type="submit" class="btn btn-success" onclick="start()"value="Chat">
var emptyCount=0;
function start(){
var text = document.getElementById('talk').value;
if(!text){
if(emptyCount == 0){
document.getElementById('bot').innerHTML = "<h2>You need to say
something first.</h2><br />";
}
else if(emptyCount ==1){
document.getElementById('bot').innerHTML = "<h2>Whats wrong
with you?</h2><br />";
}
else if(emptyCount == 2){
document.getElementById('bot').innerHTML = "<h2>If you send
another blank message I will deactive the chat button.</h2><br />";
}
else{
document.getElementById('bot').innerHTML = "<h2>Thats your
fault. Goodbye!</h2><br />";
document.getElementById('chat').style.display =
"none";
}
emptyCount ++;
}
}
Aucun commentaire:
Enregistrer un commentaire