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

WBOY
Release: 2016-06-24 12:18:13
Original
1313 people have browsed it

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>
Copy after login


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>
Copy after login

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
Just fine

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template