Script for Years....

1

116

I am looking for some sample script to populate a dropdown with the current
year (yyyy) plus. Recall seeing some time in the past.

David
 
T

Trevor Lawrence

116 said:
I am looking for some sample script to populate a dropdown with the current
year (yyyy) plus. Recall seeing some time in the past.

David

The current year plus what?
Plus 1, perhaps ?

If so, the JavaScript I have already sent can easily be modified

Something like this
<html>
<head>
<script type="text/javascript">
function nextYear() {
var d = new Date();
document.forms('form1').result.value = d.getFullYear() + 1;
}
</script>
</head>
<body>
<form name="form1" action="">
<input type="button" value="Click Here" onclick="nextYear()" /><br>
<input type="text" id="result" size="4" value="">
</form>
</body>
</html>

Not quite a drop down, but that is just a modification
 
1

116

Sorry about that. I'm thinking more along the lines of current year, with
say, next three as options.

David
 
H

Hot-text

getFullYear() + 0; <<is 2010 he ask for this one!
getFullYear() + 1; <<is 2011

Trevor Lawrence when is 116 going to get a JavaScript editor,, he can paste
the Code to his FrontPage...
I gave him a link to a good freeware JavaScript editor at the start,, it has
a good Debugger tool in it too!
it's @ http://www.yaldex.com/Free_JaveScript_Editor.htm
http://www.yaldex.com/jsfactory_pro.htm <<< the free so good who need the
PRO one

But he have time ...... and it give some of us some thing to do ..... LOOL
 
T

Trevor Lawrence

Yep, Can be done.

Maybe tomorrow - it 18:15 AEDST here and time for other things than the web
 
T

Trevor Lawrence

Well, I got around to it eventually.

This will do the job.

<html>
<head>
<script type="text/javascript">
function loadDates() {
var yr = new Date().getFullYear();
var g = document.getElementById;
g('y').innerHTML = yr;
g('y1').innerHTML = yr + 1;
g('y2').innerHTML = yr + 2;
g('y3').innerHTML = yr + 3;}
</script>
</head>
<body onload="loadDates()">
<form>
<select>
<option>Select one...</option>
<option id="y"></option>
<option id="y1"></option>
<option id="y2"></option>
<option id="y3"></option>
</select>
</form>
</body>
</html>
</html>

What you do with the results after that is up to you
 
1

116

Thanks Trevor. I see what I was doing wrong. Also, I downloaded the Free
Javascript editor mentioned in another post. Has been a great help.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top