title: How do I build a "stoplight" state indicator button using jQuery?
body: <p>As my first jQuery project, I'm trying to write a "stoplight" status indicator that cycles through "off", "green", "yellow", and "red" circle images and POSTs the information so I can record it in a DB.  I'm currently trying to use the <a href="http://api.jquery.com/toggle/" rel="nofollow">toggle()</a> function, and it works except that I have no way to "initialize" the value to the preexisting database state.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>$('.stoplight').toggle(
      function () {
         $.post('post.aspx', { recordid: &lt;%= this.Id %&gt;, lightid: this.id, value: 'yellow' });
         $(this).attr('src', '/Images/Stoplights/yellowStatus.gif');
      },
      function () {
         $.post('post.aspx', { recordid: &lt;%= this.Id %&gt;, lightid: this.id, value: 'red' });
         $(this).attr('src', '/Images/Stoplights/redStatus.gif');
      },
      // ... and so forth for "off" and "green" settings
  </code></pre>
  
  <p>So - how do I set up the starting state of the toggle somehow during page load, or alternatively, is there another method by which I could implement this better?</p>