Posted by: nyshangal March 29, 2011
IT -- Solutions Center[Forum]
Login in to Rate this Post:     0       ?        
i have a js issue,
i have this code ,

 stepForm.find   ('select.joined-date').bind('change', function () {
        var set = $('select.joined-date[rel="'+$(this).attr('rel')+'"]'),
            jMonth = set.filter('.month'),
            jDay = set.filter('.day'),
            jYear = set.filter('.year'),
            month = parseInt(jMonth.val()),
            day = parseInt(jDay.val()),
            year = parseInt(jYear.val()),
            date = (new Date()),
            // Is the coming february in a leap year?
            leap = date.getMonth() >= 1? (((year+1)%4)==0) : ((year%4)==0),
            dateText = ',
            yearText = ',
            days=30,
            future = jMonth.data('maxDaysFuture') || 365;

        if (!day) dateText = jDay.find('option:first').html();
        if (!year) yearText = jYear.find('option:first').html();
       
        if (!month) return;
        date.setDate(1);
        date.setMonth(month);
        date.setDate(0);
        var days = date.getDate();
       
        jDay.children().remove();
        if (dateText) jDay.append($('<option>').val(').html(dateText).attr('selected', false));       
        for (i=1; i<=days; i++) jDay.append($('<option>').val(i).html(i).attr('selected', day==i));
       
        if (!day) return;
        date.setDate(1);
        date.setMonth(month-1);
        date.setDate(day);
       
        if (date.getTime() < (new Date()).getTime())
            date.setFullYear(date.getFullYear()+1);
        minyear = date.getFullYear();
        date.setDate(date.getDate()+future);
        maxyear = date.getFullYear();
        jYear.children().remove();
        new Option(yearText, ', false)
       
        if (yearText) jYear.append($('<option>').val(').html(yearText).attr('selected', false));
       
        jYear.append($('<option>').val(minyear).html(minyear).attr('selected', year==minyear));
    });

what this code is doing is when user selects a month in a date drop down, it adds number of days in day dropdown,
now i want just a opposite of what it is there,
if  a user selects a day then a month should be appended in month field..
:/
how to do that
Read Full Discussion Thread for this article