// ==UserScript== // @name Preventions year picker // @namespace stanscript // @description Lists years // @include *oscarPrevention/AddPreventionData.jsp* // @version 1 // @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js // @grant none // ==/UserScript== var d = new Date(); var n = d.getFullYear(); var myYears = [] for(i=0; i<17; i++){ myYears[i] = n-i-1 } function myFunction() { var x = document.createElement("SELECT"); x.setAttribute("id", "mySelect"); x.setAttribute("style", "width:60px;font-size:16px;position:fixed;top:50px;left:50px; "); for(i=0; i<17; i++){ document.body.appendChild(x); var z = document.createElement("option"); z.setAttribute("value", myYears[i]); var t = document.createTextNode(myYears[i]); z.appendChild(t); z.onclick = showalert document.getElementById("mySelect").appendChild(z); } } myFunction() document.getElementById("mySelect").size = "17"; function showalert(){ var x = document.getElementById("mySelect").value; $('#prevDate').val(x+"-11-01") }