help, stuck with logic variable comparison loop, javascript

Posted by Jamex on Stack Overflow See other posts from Stack Overflow or by Jamex
Published on 2010-06-08T22:28:51Z Indexed on 2010/06/08 22:32 UTC
Read the original article Hit count: 210

Filed under:
|
|

I have an input text box for search of input, the id of the text box is: id="search".

if a user enters 'cat' at first and hit search.

In the function, I get the value 'cat' by using the syntax:

var input = document.getElementById("search").value;

After that, the user enter 'dog' in the search box and hit search using the same function.

The function would assign 'dog' to the input variable.

How would I compare the current value (dog) to the previously entered value (cat)?

I have tried to assign the original input with a statement, something like

var orig = input;

but that would only overwrite the original input with the new input.

What is the logical approach to this problem.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about logic