I have this function for a small chat system that I'm working on. When the users types "shout" preceded by some text (ex: "shout hello!"). I want only the "hello!" to output (the rest should be ignored). This worked fine when I only had one command. But now I have "shout" & "message". I tried doing something with the code below but it doesn't seem to work:
function checkValue() {
var value = document.getElementById("thisinput").value;
// output text without "message" in front
if (value == "message") {
$('#output').html(value.replace('message', ''));
}
// output text without "shout" in front
else if (value == "shout") {
$('#output').html(value.replace('shout', ''));
}
// output nothing
}
Thanks!
try