title: Checking the text input before triggering event in javascript
body: <p>Basically, I am trying to create a text-based adventure game. I managed to figure out how to make text output in html's textarea through simple onclick button, but now I am trying to do something new. I am having trouble with doing same thing but with input text where users can write anything in the box and then click on the button. Right now, I am trying to make this program to check the user input against some flag (in this case, I set my flag equal to 'pizza') before it does something. Unfortunately, my code doesn't work at all. I think I don't completely understand how the input is being passed around in javascript's functions. </p>
  
  <p>The javascript part</p>
  
  <pre><code>function record(test) {
              var input = document.getElementById('filename');
              fileName = input.value;
              if (fileName == "pizza") {
              var obj=document.getElementById(test);
              obj.value="is this showing up in the textarea???"; 
              }
                          else {obj.value="wrong password!"; }
  
          }
  </code></pre>
  
  <p>The html part.</p>
  
  <pre><code>&lt;input name="filename" id="filename" type="text"&gt;
  
  &lt;a id="record_button" onclick="record('textarea1');" href="javascript:void(0);" title="Record"&gt;Perform Action&lt;/a&gt;
  
  &lt;textarea wrap="virtual" cols="73" rows="10" id="textarea1"&gt;&lt;/textarea&gt;
  </code></pre>