javascript - Reverse JS select menu order and add custom option at the end -


I am slightly new to JS, so I apologize in advance if I ask any stupid questions.

I found this script in script overflow and made some small tweaks. With the help of script Calvin, the user comes from "user2935177" My problem is that I want to change the order of the year (new, old) and adding a custom option below ("before 50s"). I have received many questions / answers about giving custom order in JS but in the code it is novice to implement it.

Whoever is willing to help and if possible, how can I finally add a custom option from the list?

  & lt; Script & gt; Var max = new date (). Choose GetFullYear (), minimum = 1930 = document.getElementById ('selectElementId'); {Var opt = document.createElement ('option') for (Var i = min; i & lt; = max; i ++); Opt.value = i; Opt.text = i; Select.appendChild (optional); } & Lt; / Script & gt;   

Many, many thanks in advance!

Change your loop to maximize, and instead of going back to the minute, go to the < / P> >

and then add it after your loop:

  var customOpt = document.createElement ('option'); CustomOpt.value = -1; // whatever value you want is that it is customOpt.text = "before 1950"; Select.appendChild (customOpt);    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -