title: really simple javascript to remove value in text box
body: <p>iv got a really simple javascript question. Ill be using query for parts of it here but there are akin ways of doing it via javascript. basically, I'm writing a little script that makes it so when you click a text box with a value in it, it will take out the value so your can type (ex for most username boxes they have a little note in there). there are probably much better ways of doing this (i can already think of some) so feel free to suggest them as well. anyways I got that part running easily, the problem is that whenever a user clicks again all the data is removed, so if they just want to adjust something they can't. to solve this (ill show code in sec) i put a check variable and an if. this is what it looks like. (it doesn't work, btw)</p>
  
  <pre><code>var unumber = 0;
  var pnumber = 0; 
  
   if(unumber&lt;1){
    $('#username').click(function(){
    unumber = 1;
    $('#username').val('');
   });
   };
  
   if(pnumber&lt;1){
     $('#password').click(function(){
     $('#password').val('');
     pnumber = 1;
     });
   };
  </code></pre>
  
  <p>what I'm assuming happens is that every time some one clicks the variables are reset, and this leads to a more general question if this is this case, why would the whole script, not just the event handler, run? Im new to javascript so forgive me if this is a stupid question. Anyways, this is a really simple script and there are better and more efficient ways to do it, but how can it be done this way?</p>