Hi All, I've got a webpage with a text box in, which the user can type text into (obviously!). Im trying to figure out how to make it so that if a user types the word "cat" then in another text box somewhere else on the page the word "dog" appears. Does anybody know how to do this? It seems pretty difficult because there needs to be a way to distinguish between words in a text box. Your help is much appreciated! Thanks!
Do you want it to happen in real time, as the person is typing? If so, this looks like a JavaScript question, not a PHP question. Otherwise, if you're willing or able to wait until the form is submitted: $words = preg_split('/\W+/', strtolower($_REQUEST['cat_field'])); if (in_array('cat', $words)) $dog_field = "dog"; Code (markup):
Thanks small potatoes. Yes, ideally I wanted it realtime - oh well, looks like Im going to have to learn Javascript now!