Jump to content

simple javascript conversation and response


gongpex

Recommended Posts

Hello everyone, I think you must see this code and result :

<html><head></head><body> D : C who you choose A or B ? <br />C : I definitely choose : <input type="text" size="1" maxlength="1" /><br /><button>Get the answer!</button><br /><br /> response : <br /> (if user type B on input column it will shown : ) <br /><br /> A : you really ungrateful C , so sadness I can become your friend <br /><br /> (if user type A on input column it will shown : ) <br /><br /> B : C,  I'am very disappointed at you, from this moment we are not friend! <br /><br /> (if user type other like D,E till Z on column, it will shown  <br /><br /> A & B : C, From this moment you are not my friend !!!! </body></html>

Question :- To create conversation and response like this, should I combine javascript with PHP or etc?- If using only javascript, can I make conversation like this? please someone answer me Thanks_____________________________________________________________________________________________________ Note : I create conversation like this just to make people understand easily with my question, please don't feel offensive. Thanks

Edited by gong
Link to comment
Share on other sites

unless your going to retrieve values from a database I don't see any reason to use PHP. I'm sure you can craft something like this in javascript.

Link to comment
Share on other sites

Using DOM methods you can access the contents of <input>, <select> and <textarea> elements. One of the most useful tools is getElementById(). Once you have the element, if it is an <input> or a <textarea> element you can use the value property to access the data within it. In the case of a checkbox or radio button, the input has a checked property. In the case of a <select> element you can get the selected <option> element using the selectedIndex in combination with the options[] node list. The <option> element has a value property as well.

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...