简体   繁体   中英

drop down list for years

I am currently trying to create a payment form. I am trying to create a payment form like the ones on the online shopping websites. I have created drop down lists for type of credit card and months but I'm not to sure about the year drop down list. Would I use the same code as I did for months and type of credit cards? Do I just put all the years manually or is the another way to do it?

HTML nor JS don´t know <credit_card_year> tag.

So use <select> tag with next few (three, four?) years.

Manually is the safest choice but you can do it in JS or backend server..

Presume that the year starts on the current year.. then and you are using jQuery

var years = $('<select>');
var currnet_year = new Date().getFullYear();
 for(var i =1; i < 51; i++){
   var n_y =(currnet_year +i);
   years.append( $('<option>',{ text: (n_y ), value:n_y  }) );
 }

append the years everyware you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM