javascript select
<select name="gender" style="width:200; margin-left:50px;" id="Yearselect"><script type="text/javascript"> var yselect=document.getElementById("Yearselect") var year = new Date() var nYear = year.getFullYear() while(nYear >= 1970 ) { yselect.options.add(new Option(nYear + "年", nYear-1970))//这里的年怎么就加不上? nYear-- }</script></select>
What do you mean? Is it that the year value cannot be added or the otpion item cannot be added?
yselect.options.add(new Option(nYear, nYear-1970))//The year can be displayed such as 2013, but I want to add a "year" at the end "Word
yselect.options.add(new Option(nYear "Year", nYear-1970))//Not even the year is displayed, there is nothing at all
<html><head></head><body> <select name="gender" style="width:200; margin-left:50px;" id="Yearselect"> </select></body><script type="text/javascript"> var yselect=document.getElementById("Yearselect") var year = new Date() var nYear = year.getFullYear() while(nYear >= 1970 ) { yselect.options.add(new Option(nYear + "年", nYear-1970))//这里的年怎么就加不上? nYear-- } </script></html>
I added a
Just fine