473,804 Members | 3,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

drop down box upto current year/populate with current month

79 New Member
i have created following drop down box for displaying year... i want to populate the drop down box upto current year.. and need to write a java script for this .. any pointers in this regard will be very helpful
Expand|Select|Wrap|Line Numbers
  1. <select name=year>
  2. <option value=2008>2008</option>
  3. <option value=2007>2007</option>
  4. <option value=2006>2006</option>
  5. </select>
  6.  
Mar 7 '08 #1
6 27210
dlite922
1,584 Recognized Expert Top Contributor
i have created following drop down box for displaying year... i want to populate the drop down box upto current year.. and need to write a java script for this .. any pointers in this regard will be very helpful
Expand|Select|Wrap|Line Numbers
  1. <select name=year>
  2. <option value=2008>2008</option>
  3. <option value=2007>2007</option>
  4. <option value=2006>2006</option>
  5. </select>
  6.  
here's a start...

Expand|Select|Wrap|Line Numbers
  1. function populateYearSelect()
  2. {
  3.     d = new Date();
  4.     curr_year = d.getFullYear();
  5.  
  6.     for(i = 0; i < 3; i++)
  7.     {
  8.         document.getElementById('year').options[i] = new Option(curr_year-i,curr_year-i);
  9.     }
  10. }
[HTML]

<body onLoad="populat eYearSelect()">

<select name="year" id="year">
// options generated dynamically
</select>

</body>
[/HTML]

that should be start. i just wrote it off the top of my head so take it and run with it!

Good luck.
Mar 7 '08 #2
abhishekbrave
79 New Member
here's a start...

Expand|Select|Wrap|Line Numbers
  1. function populateYearSelect()
  2. {
  3.     d = new Date();
  4.     curr_year = d.getFullYear();
  5.  
  6.     for(i = 0; i < 3; i++)
  7.     {
  8.         document.getElementById('year').options[i] = new Option(curr_year-i,curr_year-i);
  9.     }
  10. }
[HTML]

<body onLoad="populat eYearSelect()">

<select name="year" id="year">
// options generated dynamically
</select>

</body>
[/HTML]

that should be start. i just wrote it off the top of my head so take it and run with it!

Good luck.
hey thanx i am able to get current year populated by doing some workaround.
Mar 15 '08 #3
abhishekbrave
79 New Member
I have created a drop down box for displaying month.But I want to show current month in the drop down box .
[HTML]
<select name=month onChange="setMo nth(value)">
<option value=01>JAN</option>
<option value=02>FEB</option>
<option value=03>MAR</option>
<option value=04>APR</option>
<option value=05>MAY</option>
<option value=06>JUN</option>
<option value=07>JUL</option>
<option value=08>AUG</option>
<option value=09>SEP</option>
<option value=10>OCT</option>
<option value=11>NOV</option>
<option value=12>DEC</option>
</select>
[/HTML]

Now I need to write a java script so that the drop down box will show intially the current month. For example the current month is march therefore the drop dow box should show intially march as the current month.

Need to know how to start it with java scripts any pointers will be very helpful.
Mar 15 '08 #4
abhishekbrave
79 New Member
hey thanx i am able to get current year populated by doing some workaround.
thanx for the previous reply the next thing i want is to show current month in the drop down box.

[HTML]
<select name=month onChange="setMo nth(value)">
<option value=01>JAN</option>
<option value=02>FEB</option>
<option value=03>MAR</option>
<option value=04>APR</option>
<option value=05>MAY</option>
<option value=06>JUN</option>
<option value=07>JUL</option>
<option value=08>AUG</option>
<option value=09>SEP</option>
<option value=10>OCT</option>
<option value=11>NOV</option>
<option value=12>DEC</option>
</select>

[/HTML]
hope u ll help me here also
:) thnax
Mar 15 '08 #5
abhishekbrave
79 New Member
Hi ,

I got the solution of this problem
Only need to add following lines of code in the script

curr_month = d.getMonth;
document.month. options[curr_month].selected=true;

thanx for the previous reply the next thing i want is to show current month in the drop down box.

[HTML]
<select name=month onChange="setMo nth(value)">
<option value=01>JAN</option>
<option value=02>FEB</option>
<option value=03>MAR</option>
<option value=04>APR</option>
<option value=05>MAY</option>
<option value=06>JUN</option>
<option value=07>JUL</option>
<option value=08>AUG</option>
<option value=09>SEP</option>
<option value=10>OCT</option>
<option value=11>NOV</option>
<option value=12>DEC</option>
</select>

[/HTML]
hope u ll help me here also
:) thnax
Mar 15 '08 #6
abhishekbrave
79 New Member
Hi ,

I got the solution of this problem
Only need to add following lines of code in the script
Expand|Select|Wrap|Line Numbers
  1. curr_month = d.getMonth;
  2. document.month.options[curr_month].selected=true;
  3.  
I have created a drop down box for displaying month.But I want to show current month in the drop down box .
[HTML]
<select name=month onChange="setMo nth(value)">
<option value=01>JAN</option>
<option value=02>FEB</option>
<option value=03>MAR</option>
<option value=04>APR</option>
<option value=05>MAY</option>
<option value=06>JUN</option>
<option value=07>JUL</option>
<option value=08>AUG</option>
<option value=09>SEP</option>
<option value=10>OCT</option>
<option value=11>NOV</option>
<option value=12>DEC</option>
</select>
[/HTML]

Now I need to write a java script so that the drop down box will show intially the current month. For example the current month is march therefore the drop dow box should show intially march as the current month.

Need to know how to start it with java scripts any pointers will be very helpful.
Mar 15 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2851
by: Nanos | last post by:
For the form I need to create drop down select with say five different options. There also should be possibility to enter own option if one is not listed. How can I do it.? Thank you in advance for any hint, emanuel
2
1108
by: p3x573 | last post by:
Hey everyone, I've been reading over this newsgroup and you all seem like a bunch of very knowledgeable people. So maybe you can point me in the right direction. What I am trying to do is this... I have a web site where I am selling wheels and tires. I want to have the user select from drop down menus, the year, then make, then model of their car, then have the site display the wheels that will fit that vehicle.
3
2537
by: JSubadhra | last post by:
Hi, I am very new to ASP. I am trying to change another person's code. I googled my query and read a lot of ideas. But my problem is as I try to change one thing, someother code gets affected. SO I have decided to modify the code I have to do the task. I really need some help here. The task is -- I have 3 drop down boxes, country, state, city. The state has to populate based on country ....
3
37694
by: rgsw | last post by:
I would like to create a drop down list in a form. When month is selected I would like information for that month only to show in form. Would I have to connect to a different table for each month? How would this drop down list be created in form? Usually I have transferred information to an excel spreadsheet then delete entries and start over in next month. But I would like all months entries to be in the database without transferring to...
3
7362
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the document selected (my application uses the BusinessObjects Java Web Services SDK) The 2nd list is dependent on the 1st, while the 3rd list is dependent on the 2nd. In other words, this is what i want my application to do -select a folder from the...
8
3317
by: dskanth | last post by:
I have 4 drop down lists, namely Location, country, State and City. Ex: Location: Asia, Country: India, State: Andhra Pradesh, City: Hyderabad. If i select any option in the Location drop down list, it should populate the country drop down list, and if i select an option in country drop down list, it should populate the state drop down list, and if i select any option in the state drop down list, it should populate the city drop down...
6
3240
by: olala123 | last post by:
i have created following drop down box for displaying year... i want to populate the drop down box upto current year.. and need to write a java script for this .. any pointers in this regard will be very helpful Code: ( text ) <select name=year> <option value=2008>2008</option> <option value=2007>2007</option> <option value=2006>2006</option> </select>
5
2678
by: atlanteavila | last post by:
Hello all, I've attached a database here that we're using to register people for a series of classes, for a course that we're offering for pre-baptismal certification. I'm wondering if there is a way that we could use one selection from the drop down list to auto populate the entire course dates in the sub form. That way, we would only select one item instead of having to select every class individually for every person that registers. ...
0
1099
by: alphanj | last post by:
Hi 1-Is there a way to have to make a drop-down field and and populate it using a macro? 2-Is there any way to edit drop-down field code ( I mean { FORMDROPDOWN } not through dialogue box.
1
2542
by: yenom red | last post by:
i have a drop down list tied to a database called location. what i hope to achieve is once a location is selected, my other drop down list will auto-populate a list of department in that location. how do i go about on connecting the two drop down list together so when location is changed, it connects to the appropriate row in the database?
0
9589
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10593
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10329
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.