Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Help Creating A Dynamic Credit Card Dropdown

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #42902
    jcoder
    Member

    Hello All,

    I am trying to create a dynamic dropdown that will take the current year and iterate another 15 years to it so I don’t have to continue to update the credit card year dropdown field. I have successfully built the for loop but cannot seem to figure out how to put this inside a select tag.

    Any help would be great!

    Here is the for loop that iterates the date. Here is my [CodePen](http://www.codepen.io/jbatzel1Development/pen/kebpn “CodePen”)

    var date = new Date().getFullYear();
    var length = date + 16;

    for(var i = date; i < length; i++){
    document.write(“
    ” + i + “
    “);
    }

    #125549
    Paulie_D
    Member

    @JoshBlackwood

    Lovely….

    #125563
    jcoder
    Member

    @JoshBlackwood, Thanks for the help and multiple versions! That’s a good point on JavaScript being disabled, but I learned some new stuff : )

    Thanks!

    #147589
    maspoch
    Participant

    Hi @JoshBlackwood, this was exactly what i was looking for even though it’ll probably get taken out since we’ll have nothing if the user disables Javascript but I wanted to know how you would do this for the months category. I’m new to JS so sorry if it’s simple I just don’t know how to do it and there’s not a lot online about credit card expiry dropdowns, i thought there would be. thanks in advance.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.