Jump to content

Please help me


Naosyth

Recommended Posts

Ok, i want this to reply in a form to stuff i type... 10 minutes ago it worked, but i did something and now it wont work and i cant figure out why...<html><head><script language="text/javascript">var word=getElementById("word")function chat(word){if(document.getElementById("word").value=="hi")document.getElementById("reply").value="Hello."if(document.getElementById("word").value=="how are you?")document.getElementById("reply").value="Im good."if(document.getElementById("word").value=="do you like pie?")document.getElementById("reply").value="Of course I do!"if(document.getElementById("word").value=="do you know tycho?")document.getElementById("reply").value="Yeah, we go way back."if(document.getElementById("word").value=="what is your name?")document.getElementById("reply").value="My name is Naosyth2.0"}</script></head><body><center><form><input type="text" id="word"><br><input type="button" value="Say" onclick="chat(word)"></form><br><form><input type="text" id="reply" size="100"></form></center></body></html>Im prety sure the problem is at the beginning with my function... but i cant see anything wrong with it.

Link to comment
Share on other sites

Try this.

<html><head><script type="text/javascript">var word=getElementById("word")function chat(word){if(document.getElementById("word").value=="hi")document.getElementById("reply").value="Hello."if(document.getElementById("word").value=="how are you?")document.getElementById("reply").value="Im good."if(document.getElementById("word").value=="do you like pie?")document.getElementById("reply").value="Of course I do!"if(document.getElementById("word").value=="do you know tycho?")document.getElementById("reply").value="Yeah, we go way back."if(document.getElementById("word").value=="what is your name?")document.getElementById("reply").value="My name is Naosyth2.0"}</script></head><body><center><form><input type="text" id="word"><br><input type="button" value="Say" onclick="chat(word)"></form><br><form><input type="text" id="reply" size="100"></form></center></body></html>

Don't use language=, use type= in the <script> tag. :)

Link to comment
Share on other sites

Ive ran into another problem... it isnt a big one but it'd be nice to fix it.Im trying to make this reply to stuff i say, and it does.. but i want the text in the word box to disappear when i hit enter. But i dont want the text in the reply box to go away.

<html><head><script type="text/javascript">function noenter() {chat()clear() return !(window.event && window.event.keyCode == 13);}</script><script type="text/javascript">function clear(){document.getElementById("word").value=""}</script><script type="text/javascript">function chat(word){//hi,bye,small talkif(document.getElementById("word").value=="hi")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="hello")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="hey")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hi")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hello")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hey")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="how are you?")document.getElementById("reply").value="Naosyth2.0: Im good, and you?"if(document.getElementById("word").value=="good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="im good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="How are you?")document.getElementById("reply").value="Naosyth2.0: Im good, and you?"if(document.getElementById("word").value=="Good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="Im good")document.getElementById("reply").value="Naosyth2.0: Thats good"//randomnessif(document.getElementById("word").value=="do you like pie?")document.getElementById("reply").value="Naosyth2.0: Of course I do!"if(document.getElementById("word").value=="do you know tycho?")document.getElementById("reply").value="Naosyth2.0: Yeah, we go way back."//questionsif(document.getElementById("word").value=="what is your name?")document.getElementById("reply").value="Naosyth2.0: My name is Naosyth2.0"if(document.getElementById("word").value=="who is naosyth?")document.getElementById("reply").value="Naosyth2.0: He is the coolest person in the world!!!"if(document.getElementById("word").value=="who is hybrid mouse?")document.getElementById("reply").value="Naosyth2.0: A person who thinks i am a pathetic bot! >:("if(document.getElementById("word").value=="who is chewy?")document.getElementById("reply").value="The most awesome giant yorkie ever!"//prices//special}</script></head><body bgcolor=202020><br><br><br><center><form><input type="text" id="word" bgcolor=202020 style="background:808080" onkeypress="return noenter()"><br><input type="button" value="Say" onclick="chat(word)" style="background:808080"></form><br><form><input type="text" id="reply" size="100" style="background:808080"></form></script><br><br><br><br><br><br><br><br><br><table border=0 bgcolor=404040 width=50% height=20%><tr><td><center>I am the not so amazing talking bot named Naosyth2.0.<br> I can reply to some things you say to me.</center></td></tr></table></center></body></html>

You can try it at http://naosyth.com/Misc/TalkBot.htmlThanks :)

Link to comment
Share on other sites

Hello again!

<html><head><script type="text/javascript">function trythekey(e) {	var code;	if (!e) var e = window.event;	if (e.keyCode) code = e.keyCode;	else if (e.which) code = e.which;        if(code=="13") chat();}function chat(word){//hi,bye,small talkif(document.getElementById("word").value=="hi")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="hello")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="hey")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hi")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hello")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hey")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="how are you?")document.getElementById("reply").value="Naosyth2.0: Im good, and you?"if(document.getElementById("word").value=="good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="im good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="How are you?")document.getElementById("reply").value="Naosyth2.0: Im good, and you?"if(document.getElementById("word").value=="Good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="Im good")document.getElementById("reply").value="Naosyth2.0: Thats good"//randomnessif(document.getElementById("word").value=="do you like pie?")document.getElementById("reply").value="Naosyth2.0: Of course I do!"if(document.getElementById("word").value=="do you know tycho?")document.getElementById("reply").value="Naosyth2.0: Yeah, we go way back."//questionsif(document.getElementById("word").value=="what is your name?")document.getElementById("reply").value="Naosyth2.0: My name is Naosyth2.0"if(document.getElementById("word").value=="who is naosyth?")document.getElementById("reply").value="Naosyth2.0: He is the coolest person in the world!!!"if(document.getElementById("word").value=="who is hybrid mouse?")document.getElementById("reply").value="Naosyth2.0: A person who thinks i am a pathetic bot! >"if(document.getElementById("word").value=="who is chewy?")document.getElementById("reply").value="The most awesome giant yorkie ever!"//prices//specialdocument.getElementById("word").value=""}</script></head><body onkeypress="trythekey(event)" bgcolor=202020><br><br><br><center><form><input type="text" id="word" bgcolor=202020 style="background:808080" onkeypress="noenter()"><br><input type="button" value="Say" onclick="chat(word)" style="background:808080"></form><br><form><input type="text" id="reply" size="100" style="background:808080"></form></script><br><br><br><br><br><br><br><br><br><table border=0 bgcolor=404040 width=50% height=20%><tr><td><center>I am the not so amazing talking bot named Naosyth2.0.<br> I can reply to some things you say to me.</center></td></tr></table></center></body></html>

I added some code to check if the button pressed was "e". It's crossbrowser, thanks to Quirksmode! If you press enter, it clears the word box and changes the reply box to your reply. If you click the button, it does the same. I think that's what you want :)Choco

Link to comment
Share on other sites

Thanks again, lol. But, when i hit enter.. the reply appears and disappeares really fast. Also, in the code you posted, i tihnk this line was messed up:<input type="text" id="word" bgcolor=202020 style="background:808080" onkeypress="noenter()">so i changed it to:<input type="text" id="word" bgcolor=202020 style="background:808080" onkeypress="trythekey()">But it still is messed up...Http://naosyth.com/Misc/TalkBot.html to see for yourself.Thanks again, lolAlso, ive added some more replies:<html><head><script type="text/javascript">function trythekey(e) { var code; if (!e) var e = window.event; if (e.keyCode) code = e.keyCode; else if (e.which) code = e.which; if(code=="13") chat();}function chat(word){//hi,bye,small talkif(document.getElementById("word").value=="hi")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="hello")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="hey")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hi")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hello")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hey")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="bye")document.getElementById("reply").value="Naosyth2.0: Good Bye."if(document.getElementById("word").value=="cya")document.getElementById("reply").value="Naosyth2.0: Good Bye."if(document.getElementById("word").value=="good night")document.getElementById("reply").value="Naosyth2.0: Good night."if(document.getElementById("word").value=="Bye")document.getElementById("reply").value="Naosyth2.0: Good Bye."if(document.getElementById("word").value=="Bya")document.getElementById("reply").value="Naosyth2.0: Good Bye."if(document.getElementById("word").value=="Good night")document.getElementById("reply").value="Naosyth2.0: Good night."if(document.getElementById("word").value=="how are you?")document.getElementById("reply").value="Naosyth2.0: Im good, and you?"if(document.getElementById("word").value=="good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="im good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="How are you?")document.getElementById("reply").value="Naosyth2.0: Im good, and you?"if(document.getElementById("word").value=="Good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="Im good")document.getElementById("reply").value="Naosyth2.0: Thats good"//randomnessif(document.getElementById("word").value=="do you like pie?")document.getElementById("reply").value="Naosyth2.0: Of course I do!"if(document.getElementById("word").value=="Do you like pie?")document.getElementById("reply").value="Naosyth2.0: Of course I do!"if(document.getElementById("word").value=="can i have pie?")document.getElementById("reply").value="Naosyth2.0: No! All of the pie is for me!"if(document.getElementById("word").value=="Can i have pie?")document.getElementById("reply").value="Naosyth2.0: No! All of the pie is for me!"if(document.getElementById("word").value=="do you know tycho?")document.getElementById("reply").value="Naosyth2.0: Yeah, we go way back."if(document.getElementById("word").value=="Do you know tycho?")document.getElementById("reply").value="Naosyth2.0: Yeah, we go way back."//questionsif(document.getElementById("word").value=="what is your name?")document.getElementById("reply").value="Naosyth2.0: My name is Naosyth2.0"if(document.getElementById("word").value=="What is your name?")document.getElementById("reply").value="Naosyth2.0: My name is Naosyth2.0"if(document.getElementById("word").value=="who is naosyth?")document.getElementById("reply").value="Naosyth2.0: He is the coolest person in the world!!!"if(document.getElementById("word").value=="Who is naosyth?")document.getElementById("reply").value="Naosyth2.0: He is the coolest person in the world!!!"if(document.getElementById("word").value=="who is hybrid mouse?")document.getElementById("reply").value="Naosyth2.0: A person who thinks i am a pathetic bot! >:)"if(document.getElementById("word").value=="Who is hybrid mouse?")document.getElementById("reply").value="Naosyth2.0: A person who thinks i am a pathetic bot! >:)"if(document.getElementById("word").value=="who is chewy?")document.getElementById("reply").value="The most awesome giant yorkie ever!"if(document.getElementById("word").value=="Who is chewy?")document.getElementById("reply").value="The most awesome giant yorkie ever!"//pricesif(document.getElementById("word").value=="how much is sig 1?")document.getElementById("reply").value="Sig 1 (qwerty) costs 400 gold."if(document.getElementById("word").value=="How much is sig 1?")document.getElementById("reply").value="Sig 1 (qwerty) costs 400 gold."//specialdocument.getElementById("word").value=""}</script></head><body onkeypress="trythekey(event)" bgcolor=202020><br><br><br><center><form><input type="text" id="word" bgcolor=202020 style="background:808080" onkeypress="trythekey(e)"><br><input type="button" value="Say" onclick="chat(word)" style="background:808080"></form><br><form><input type="text" id="reply" size="100" style="background:808080"></form></script><br><br><br><br><br><br><br><br><br><table border=0 bgcolor=404040 width=50% height=20%><tr><td><center>I am the not so amazing talking bot named Naosyth2.0.<br> I can reply to some things you say to me.</center></td></tr></table></center></body></html>

Link to comment
Share on other sites

This works in Opera 9.0,Opera 8.0, FireFox 1.5, FireFox 2 beta 2, IE 6, and IE 5. I think most of your users will be able to display this. :)Also, you might want to consider changing the background of the form elements. They're super-hard to see in IE and Opera, but are so-and-so in FireFox. Here's the code:

<html><head><script type="text/javascript">function trythekey(e) {var code;if (!e) var e = window.event;if (e.keyCode) code = e.keyCode;else if (e.which) code = e.which;if(code=="13") chat();}function chat(word){//hi,bye,small talkif(document.getElementById("word").value=="hi")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="hello")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="hey")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hi")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hello")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="Hey")document.getElementById("reply").value="Naosyth2.0: Hello."if(document.getElementById("word").value=="bye")document.getElementById("reply").value="Naosyth2.0: Good Bye."if(document.getElementById("word").value=="cya")document.getElementById("reply").value="Naosyth2.0: Good Bye."if(document.getElementById("word").value=="good night")document.getElementById("reply").value="Naosyth2.0: Good night."if(document.getElementById("word").value=="Bye")document.getElementById("reply").value="Naosyth2.0: Good Bye."if(document.getElementById("word").value=="Bya")document.getElementById("reply").value="Naosyth2.0: Good Bye."if(document.getElementById("word").value=="Good night")document.getElementById("reply").value="Naosyth2.0: Good night."if(document.getElementById("word").value=="how are you?")document.getElementById("reply").value="Naosyth2.0: Im good, and you?"if(document.getElementById("word").value=="good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="im good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="How are you?")document.getElementById("reply").value="Naosyth2.0: Im good, and you?"if(document.getElementById("word").value=="Good")document.getElementById("reply").value="Naosyth2.0: Thats good"if(document.getElementById("word").value=="Im good")document.getElementById("reply").value="Naosyth2.0: Thats good"//randomnessif(document.getElementById("word").value=="do you like pie?")document.getElementById("reply").value="Naosyth2.0: Of course I do!"if(document.getElementById("word").value=="Do you like pie?")document.getElementById("reply").value="Naosyth2.0: Of course I do!"if(document.getElementById("word").value=="can i have pie?")document.getElementById("reply").value="Naosyth2.0: No! All of the pie is for me!"if(document.getElementById("word").value=="Can i have pie?")document.getElementById("reply").value="Naosyth2.0: No! All of the pie is for me!"if(document.getElementById("word").value=="do you know tycho?")document.getElementById("reply").value="Naosyth2.0: Yeah, we go way back."if(document.getElementById("word").value=="Do you know tycho?")document.getElementById("reply").value="Naosyth2.0: Yeah, we go way back."//questionsif(document.getElementById("word").value=="what is your name?")document.getElementById("reply").value="Naosyth2.0: My name is Naosyth2.0"if(document.getElementById("word").value=="What is your name?")document.getElementById("reply").value="Naosyth2.0: My name is Naosyth2.0"if(document.getElementById("word").value=="who is naosyth?")document.getElementById("reply").value="Naosyth2.0: He is the coolest person in the world!!!"if(document.getElementById("word").value=="Who is naosyth?")document.getElementById("reply").value="Naosyth2.0: He is the coolest person in the world!!!"if(document.getElementById("word").value=="who is hybrid mouse?")document.getElementById("reply").value="Naosyth2.0: A person who thinks i am a pathetic bot! >"if(document.getElementById("word").value=="Who is hybrid mouse?")document.getElementById("reply").value="Naosyth2.0: A person who thinks i am a pathetic bot! >"if(document.getElementById("word").value=="who is chewy?")document.getElementById("reply").value="The most awesome giant yorkie ever!"if(document.getElementById("word").value=="Who is chewy?")document.getElementById("reply").value="The most awesome giant yorkie ever!"//pricesif(document.getElementById("word").value=="how much is sig 1?")document.getElementById("reply").value="Sig 1 (qwerty) costs 400 gold."if(document.getElementById("word").value=="How much is sig 1?")document.getElementById("reply").value="Sig 1 (qwerty) costs 400 gold."//specialdocument.getElementById("word").value=""}</script></head><body onkeypress="trythekey(event)" bgcolor=202020><br><br><br><center><form onsubmit="return false;"><input type="text" id="word" bgcolor=202020 style="background:808080"><br><input type="button" value="Say" onclick="chat(word);return false;" style="background:808080"></form><br><form><input type="text" id="reply" size="100" style="background:808080"></form></script><br><br><br><br><br><br><br><br><br><table border=0 bgcolor=404040 width=50% height=20%><tr><td><center>I am the not so amazing talking bot named Naosyth2.0.<br> I can reply to some things you say tome.</center></td></tr></table></center></body></html>

Hope that helps!Choco

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...