I'm trying to create a small plugin which could be reused in some other context. I'm trying set manufacture month based on registration month. For eg, if I select the registration month as May, the manufacture month should be from January to May and so on. However my trails were gone in vein.. Here is my code

```
setManufacturedMonth($('#registrationmonth').val());
function setManufacturedMonth(regMonth) {    
    $('#manufacturemonth').empty();
     var months =  {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun',7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'};
    $.each(months, function( key, value ) {
        for(var i=1;i<=parseInt(regMonth);i++) {      

            $("<option></option>", {value: key , text:   value}).appendTo($('#manufacturemonth'));
        }
    });
}

$('#registrationmonth').change(function() {
     setManufacturedMonth($('#registrationmonth').val());
});

```

HTML Code
---------

```
 Registration Month <select id="registrationmonth">
     <option value="4">April</option>
     <option value="5">May</option>
     <option value="6">June</option>
</select>
Manufactured Month <select id="manufacturemonth">
</select>

```

Here is the fiddle created 

<http://jsfiddle.net/UECsS/34/>