Wrox Home  
Search P2P Archive for: Go

  Return to Index  

html_code_clinic thread: Future Years in Select Element


Message #1 by raymurphy@g... on Mon, 13 Aug 2001 11:10:07
Arjan,

FANTASTIC :))

I've just tried out the amended script, and it works perfectly in both 
IE and Netscape - you've saved me a lot of bother here.

Thanks.

Ray

> Netscape returns 101 for the year 2001 (year 2000 problem...)
> 
> use this script instead:
> 
> <script language="javascript">
> <!--
> function display_combo() {
> 	var thisYear,i
> 
> 	//get current date
> 	date=new Date()	
> 	
> 	//year 2000 problem in old versions of netscape
> 	if(date.getYear()<1000)
> 	{
> 		thisYear = date.getYear() + 1900;
> 	} else {
> 		thisYear = date.getYear();
> 	}
> 
> 	//write beginning of year-combo
> 	document.write('<select name=\"cboYear\">')
> 
> 	//loop through each year
> 	for(i=1996;i<=thisYear;i++) {
> 		document.write('<option value=\"' + i + '\">' + i
> +'</option>')
> 	}
> 
> 	//write end of year-combo
> 	document.write('</select>') 
> }
> //-->
> </script>
> 
> -----Original Message-----
> From: raymurphy@g... [mailto:raymurphy@g...]
> Sent: maandag 13 augustus 2001 17:19
> To: HTML Code Clinic
> Subject: [html_code_clinic] RE: Future Years in Select Element
> 
> 
> Arjan,
> 
> This solution works fine in IE, but when I tested it under Netscape 4, 
all 
> I ended up with was an empty combo-box ?? Under Netscape, viewing the 
> source reveals that the code writes out the <select> and the </select>, 
> but doesn't write out the actual year values ??
> 
> Any ideas why this should be, please ?
> 
> Thanks.
> 
> Ray
> 

  Return to Index