Q:

How would it be better to LOOP a jquery function?

I'm trying to understand a bit more of jQuery and how it works.
In my last Question user Zachary Kniebel helped me figure how to show/hide some values based on a 'RADIO' form, now I modified his code and I would like to improve it a more using a loop (maybe a FOR loop as he suggested to me).
Actually I had no luck so here is my question:
**
I forgot to say that I can't change HTML because it is automatically generated by a wordpress Option framework...
**
How is it possible to use a LOOP for this function without changing the HTML part?
For jsfiddle lovers here it is a working example with really long js CODE

JS

--
jQuery(document).ready(function ($) {
    $types = $('.of-radio');
    $types.change(function () {
        $this = $(this).val();
        if ($this == "0") {
            /* zone 1 */
            $('#section-custom_posts_name_s_n1').hide();
            $('#section-custom_posts_name_p_n1').hide();
            $('#section-custom_posts_name_i_n1').hide();
            $('#section-custom_posts_name_d_n1').hide();
            /* end zone 1 start zone 2*/
            $('#section-custom_posts_name_s_n2').hide();
            $('#section-custom_posts_name_p_n2').hide();
            $('#section-custom_posts_name_i_n2').hide();
            $('#section-custom_posts_name_d_n2').hide();
            /* end zone 2 start zone 3 */
            $('#section-custom_posts_name_s_n3').hide();
            $('#section-custom_posts_name_p_n3').hide();
            $('#section-custom_posts_name_i_n3').hide();
            $('#section-custom_posts_name_d_n3').hide();
            /* end zone 3 start zone 4 */
            $('#section-custom_posts_name_s_n4').hide();
            $('#section-custom_posts_name_p_n4').hide();
            $('#section-custom_posts_name_i_n4').hide();
            $('#section-custom_posts_name_d_n4').hide();
            /* end zone 4 start zone 5 */
            $('#section-custom_posts_name_s_n5').hide();
            $('#section-custom_posts_name_p_n5').hide();
            $('#section-custom_posts_name_i_n5').hide();            
            $('#section-custom_posts_name_d_n5').hide();
            /* end zone 5 */
        } else if ($this == "1") {
            /* start zone 1 */
            $('#section-custom_posts_name_s_n1').show();
            $('#section-custom_posts_name_p_n1').show();
            $('#section-custom_posts_name_i_n1').show();
            $('#section-custom_posts_name_d_n1').show();
            /* end zone 1 start zone 2 */
            $('#section-custom_posts_name_s_n2').hide();
            $('#section-custom_posts_name_p_n2').hide();
            $('#section-custom_posts_name_i_n2').hide();
            $('#section-custom_posts_name_d_n2').hide();
            /* end zone 2 start zone 3 */
            $('#section-custom_posts_name_s_n3').hide();
            $('#section-custom_posts_name_p_n3').hide();
            $('#section-custom_posts_name_i_n3').hide();
            $('#section-custom_posts_name_d_n3').hide();
            /* end zone 3 start zone 4 */
            $('#section-custom_posts_name_s_n4').hide();
            $('#section-custom_posts_name_p_n4').hide();
            $('#section-custom_posts_name_i_n4').hide();
            $('#section-custom_posts_name_d_n4').hide();
            /* end zone 4 start zone 5 */
            $('#section-custom_posts_name_s_n5').hide();
            $('#section-custom_posts_name_p_n5').hide();
            $('#section-custom_posts_name_i_n5').hide();            
            $('#section-custom_posts_name_d_n5').hide();
            /* end zone 5 */
        } else if ($this == "2") {
            /* start zone 1 */
            $('#section-custom_posts_name_s_n1').show();
            $('#section-custom_posts_name_p_n1').show();
            $('#section-custom_posts_name_i_n1').show();
            $('#section-custom_posts_name_d_n1').show();
            /* end zone 1 start zone 2 */
            $('#section-custom_posts_name_s_n2').show();
            $('#section-custom_posts_name_p_n2').show();
            $('#section-custom_posts_name_i_n2').show();
            $('#section-custom_posts_name_d_n2').show();
            /* end zone 2 start zone 3 */
            $('#section-custom_posts_name_s_n3').hide();
            $('#section-custom_posts_name_p_n3').hide();
            $('#section-custom_posts_name_i_n3').hide();
            $('#section-custom_posts_name_d_n3').hide();
            /* end zone 3 start zone 4 */
            $('#section-custom_posts_name_s_n4').hide();
            $('#section-custom_posts_name_p_n4').hide();
            $('#section-custom_posts_name_i_n4').hide();
            $('#section-custom_posts_name_d_n4').hide();
            /* end zone 4 start zone 5 */
            $('#section-custom_posts_name_s_n5').hide();
            $('#section-custom_posts_name_p_n5').hide();
            $('#section-custom_posts_name_i_n5').hide();
            $('#section-custom_posts_name_d_n4').hide();
            /* end zone 5 */
        } else if ($this == "3") {
            /*start zone 1 */
            $('#section-custom_posts_name_s_n1').show();
            $('#section-custom_posts_name_p_n1').show();
            $('#section-custom_posts_name_i_n1').show();
            $('#section-custom_posts_name_d_n1').show();
            /* end zone 1 start zone 2 */
            $('#section-custom_posts_name_s_n2').show();
            $('#section-custom_posts_name_p_n2').show();
            $('#section-custom_posts_name_i_n2').show();
            $('#section-custom_posts_name_d_n2').show();
            /* end zone 2 start zone 3 */
            $('#section-custom_posts_name_s_n3').show();
            $('#section-custom_posts_name_p_n3').show();
            $('#section-custom_posts_name_i_n3').show();
            $('#section-custom_posts_name_d_n3').show();
            /* end zone 3 start zone 4 */
            $('#section-custom_posts_name_s_n4').hide();
            $('#section-custom_posts_name_p_n4').hide();
            $('#section-custom_posts_name_i_n4').hide();
            $('#section-custom_posts_name_d_n4').hide();
            /* end zone 4 start zone 5 */
            $('#section-custom_posts_name_s_n5').hide();
            $('#section-custom_posts_name_p_n5').hide();
            $('#section-custom_posts_name_i_n5').hide();
            $('#section-custom_posts_name_d_n5').hide();
            /* end zone 5 */
        } else if ($this == "4") {
            /* start zone 1 */
            $('#section-custom_posts_name_s_n1').show();
            $('#section-custom_posts_name_p_n1').show();
            $('#section-custom_posts_name_i_n1').show();
            $('#section-custom_posts_name_d_n1').show();
            /* end zone 1 start zone 2 */
            $('#section-custom_posts_name_s_n2').show();
            $('#section-custom_posts_name_p_n2').show();
            $('#section-custom_posts_name_i_n2').show();
            $('#section-custom_posts_name_d_n2').show();
            /* end zone 2 start zone 3 */
            $('#section-custom_posts_name_s_n3').show();
            $('#section-custom_posts_name_p_n3').show();
            $('#section-custom_posts_name_i_n3').show();
            $('#section-custom_posts_name_d_n3').show();
            /* end zone 3 start zone 4 */
            $('#section-custom_posts_name_s_n4').show();
            $('#section-custom_posts_name_p_n4').show();
            $('#section-custom_posts_name_i_n4').show();
            $('#section-custom_posts_name_d_n4').show();
            /* end zone 4 start zone 5 */
            $('#section-custom_posts_name_s_n5').hide();
            $('#section-custom_posts_name_p_n5').hide();
            $('#section-custom_posts_name_i_n5').hide();
            $('#section-custom_posts_name_d_n5').hide();
            /* end zone 5 */
        } else if ($this == "5") {
            /* start zone 1 */
            $('#section-custom_posts_name_s_n1').show();
            $('#section-custom_posts_name_p_n1').show();
            $('#section-custom_posts_name_i_n1').show();
            $('#section-custom_posts_name_d_n1').show();
            /* end zone 1 start zone 2 */
            $('#section-custom_posts_name_s_n2').show();
            $('#section-custom_posts_name_p_n2').show();
            $('#section-custom_posts_name_i_n2').show();
            $('#section-custom_posts_name_d_n2').show();
            /* end zone 2 start zone 3 */
            $('#section-custom_posts_name_s_n3').show();
            $('#section-custom_posts_name_p_n3').show();
            $('#section-custom_posts_name_i_n3').show();
            $('#section-custom_posts_name_d_n3').show();
            /* end zone 3 start zone 4 */
            $('#section-custom_posts_name_s_n4').show();
            $('#section-custom_posts_name_p_n4').show();
            $('#section-custom_posts_name_i_n4').show();
            $('#section-custom_posts_name_d_n4').show();
            /* end zone 4 start zone 5 */
            $('#section-custom_posts_name_s_n5').show();
            $('#section-custom_posts_name_p_n5').show();
            $('#section-custom_posts_name_i_n5').show();
            $('#section-custom_posts_name_d_n5').show();
            /* end zone 5 */
        }
    });
});

A:

I'm not sure how efficient this is but this is the shortest I was able to get the code down to. I'm not sure if you are looking for efficiency or shortest way possible. Like everyone else I used loops and chaining built into jQuery.
jQuery(document).ready(function ($) {
    $types = $('.of-radio');
    $types.change(function () {
       /* $(".section").not("#section-how_many_custom_posts").hide();*/
        $this = $(this).val();
        $('[id^="section-custom_posts_name_"]').hide().each(function(i, val)
                  {
                      if($this > 0 && i < ($this * 4) && $(val).attr('id').replace( /^\D+/g, '') <= $this)
                          $(val).show();
                  });
    });
});

JSFiddle

