title: return system date on checkbox check jquery
body: <p>I am somewhat a beginner to jquery.  I am having trouble creating a function to fill a textbox with the current date when a checkbox is clicked.  I have the routine working on its own, but i would like to wrap it in a function so i can call it multiple times on the page.  I have included the code here as well as a jsfiddle link </p>
  
  <p><a href="http://jsfiddle.net/pa7vn/" rel="nofollow">jsFiddle Link</a></p>
  
  <p>html:</p>
  
  <pre><code> &lt;span id="ContentPlaceHolder1_Label8"&gt;Start Date:&lt;/span&gt;
  
          &lt;input name="ctl00$ContentPlaceHolder1$startdateSrvcTXT" type="text" id="ContentPlaceHolder1_startdateSrvcTXT" disabled="disabled" class="aspNetDisabled" /&gt;
  
          &lt;span id="ContentPlaceHolder1_Label11"&gt;Check to Start&lt;/span&gt;
  
          &lt;input id="ContentPlaceHolder1_StartFillCHK" type="checkbox" name="ctl00$ContentPlaceHolder1$StartFillCHK" /&gt;
  </code></pre>
  
  <p>javascript:</p>
  
  <pre><code>/*----This works------
  $('#ContentPlaceHolder1_StartFillCHK').click(function () {
  
                  if (this.checked) {
  
                      var myDate = new Date();
  
                      var prettyDate = (myDate.getMonth() + 1) + '.' + myDate.getDate() + '.' +
  
  myDate.getFullYear();
  
                      $('#ContentPlaceHolder1_startdateSrvcTXT').val(prettyDate);
  
                  } else { //if not checked
  
                      $('#ContentPlaceHolder1_startdateSrvcTXT').val('');
  
                  }
  
              });
  
  */
  
  //this doesnt
  function fillclick(txtid,checkid){
  $("'" + checkid + "'").click(function () {
  
                  if (this.checked) {
  
                      var myDate = new Date();
  
                      var prettyDate = (myDate.getMonth() + 1) + '.' + myDate.getDate() + '.' +
  
  myDate.getFullYear();
  
                      $("'" + txtid + "'").val(prettyDate);
  
                  } else { //if not checked
  
                      $("'" + txtid + "'").val('');
  
                  }
  
              });
  }
  
  fillclick("#ContentPlaceHolder1_startdateSrvcTXT","#ContentPlaceHolder1_StartFillCHK");
  </code></pre>