Reply
html for year of birth
Old 07-05-2007, 04:02 PM html for year of birth
Novice Talker

Posts: 13
Hi..
does someone have code i can paste into my 'year' menu.
Im just trying to cut down some time entering all the years for the dropdown menu. Its for a Year of Birth menu. im a beginner html'er

ryan
rneedham is offline
Reply With Quote
View Public Profile Visit rneedham's homepage!
 
When You Register, These Ads Go Away!
     
Old 07-06-2007, 09:41 AM Re: html for year of birth
chrishirst's Avatar
Super Moderator

Posts: 12,819
Location: Blackpool. UK
Not with HTML

but a bit of javascript will
HTML Code:
<form action="" name="formname" method="get">
<select name="year" onChange="forms['formname'].submit()">
<option value="">-- Select Year --</option>

</select>

</form>

<script type="text/javascript">
var today = new Date()
var endYear = 1946 // change to suit your oldest requirement 
var startYear= today.getFullYear()

for (startYear ;startYear>endYear; startYear--) {
	nextItem = document.forms['formname'].year.options.length;
	document.forms['formname'].year.options[nextItem] = new Option(startYear,startYear)
}
</script>
Remove the onChange event from the select box as this will submit the form
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-07-2007, 03:02 AM Re: html for year of birth
Novice Talker

Posts: 11
very kool!!!!!
legauxenterpris is offline
Reply With Quote
View Public Profile
 
Old 07-07-2007, 07:54 AM Re: html for year of birth
Ninja's Avatar
Average Talker

Posts: 18
A more accessible option would be with PHP which is another scripting language but since your a beginner just keep in mind that certain people have javascript turned off, maybe as high as 5~10%. Your server has to be set up to allow PHP code in order for you to be able to use it.
Ninja is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to html for year of birth
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14229 seconds with 13 queries