Home >Web Front-end >HTML Tutorial >I want to create a year list box, but I have a small problem_html/css_WEB-ITnose

I want to create a year list box, but I have a small problem_html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-24 12:18:131361browse

This post was last edited by liln0530 on 2013-01-10 11:03:56

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>

Reply to the discussion (solved Plan)

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>

No problem Ah, could it be a problem with the location of your js? Put it behind the body or call it when onloading

I added a d2f02d7570bfe564c2c20b62caccccab
Just fine

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn