日期:2014-05-17 浏览次数:20581 次
<html> <head> <script type="text/javascript"> var beginYear = 1990; function checkIE() { var name = navigator.appName; alert(name); if (name == "Microsoft Internet Explorer") return 1; else if (name == "Netscape") return 2; } function setIEValue() { var value = document.getElementById('value').value; for (i = beginYear; i <= value; i++) { var op = document.createElement("option"); op.text = i; op.value = i; document.getElementById('year').add(op); } } function setFFValue() { var value = document.getElementById('value').value; var out = ''; for (i = beginYear; i <= value; i++) { out += ('<option>' + i + '</option>'); } document.getElementById('year').innerHTML = out; } var flg = checkIE(); if (flg == 1) window.onload = setIEValue; else if (flg == 2) window.onload = setFFValue; </script> </head> <body> <select id="year"></select> <input id="value" type="hidden" value="[color=#FF0000]2005[/color]" /> </body> </html>
------解决方案--------------------
go create proc GetYear ( @StartYear int ) as begin declare @table table ([Year] int) while (@StartYear<=year(getdate())) begin insert into @table select @StartYear set @StartYear=@StartYear+1; end select * from @table end /*测试*/ exec GetYear 1990 /*结果 Year ----------- 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 */