How to use a switch properly in jQuery?
<pre><code>  $(document).ready(function() {
    //set all logo images based on data returned from database
    var WinBack = $('div.jWinBackFrom').html();
    switch(WinBack) {
        case '1': //If database returns 1 : set Verizon FiOS logo
        $('div.jWinBackFrom').prepend('&lt;img id="WinBackLogo" src="&lt;?php echo site_url();?&gt;/assets/images/verizon-fios-logo.jpg" /&gt;');
        break;

        case '2': //If database returns 2 : set DirecTV logo
        $('div.jWinBackFrom').prepend('&lt;img id="WinBackLogo" src="&lt;?php echo base_url();?&gt;assets/images/directv-logo.jpg" /&gt;');
        break;

        case '3': //If database returns 3 : set DISH Network logo
        $('div.jWinBackFrom').prepend('&lt;img id="WinBackLogo" src="&lt;?php echo base_url();?&gt;assets/images/dish-network-logo.jpg" /&gt;');
        break;
    }
</code></pre>

<p>On the page I have multiple <code>&lt;div class="jWinBackFrom"&gt;&lt;?php echo $optimum['cWinBackFrom'][$i]; ?&gt;&lt;/div&gt;</code> inside of for loop.</p>

<p>So imagine an output of <code>&lt;div class="jWinBackFrom"&gt;1&lt;/div&gt;</code>,<code>&lt;div class="jWinBackFrom"&gt;2&lt;/div&gt;</code>,<code>&lt;div class="jWinBackFrom"&gt;3&lt;/div&gt;</code>,<code>&lt;div class="jWinBackFrom"&gt;2&lt;/div&gt;</code>,<code>&lt;div class="jWinBackFrom"&gt;1&lt;/div&gt;``&lt;div class="jWinBackFrom"&gt;3&lt;/div&gt;</code>,<code>&lt;div class="jWinBackFrom"&gt;1&lt;/div&gt;</code>
Basically all random. The jQuery needs to get the values from all of these DIV's and switch the numeric value with the associated image.</p>

<p>Can someone tell me if I'm doing this right (meaning proper method) is this the most efficient (probably not) So what is?</p>

<p>I need to repeat this process for many other fields. My theory is that it is faster to have the DB return a simple value like 1 and use jQuery to dynamically build the page.</p>

<p>I appreciate the help! THANK YOU!</p>
