javascript - Change year/date format in option value="" -


i have dropdown shows options year 2014 , following ten years. code:

 <select name="expiry_date" id="expiry_date" class='details_card_expiry_year'> <option value="">- select year -</option> 

the script

            var min = new date().getfullyear(),             max = min + 10,             select = document.getelementbyid('expiry_date');              (var = min; i<=max; i++){             var opt = document.createelement('option');             opt.value = i;             opt.innerhtml = i;             select.appendchild(opt);             } 

however don't want value show year '2014' instead must '14'. how done?

instead of

opt.innerhtml = i; 

you can use

opt.innerhtml = string(i).slice(2); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -