473,671 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get dynamic yyyymm dropdown field in jsp?

24 New Member
Hi,
I have two fields of date in this format yyyymm(from date and to date)
I have the following code:
Expand|Select|Wrap|Line Numbers
  1. function populateYearSelect() 
  2.             { 
  3.                 d = new Date(); 
  4.                 curr_year = d.getFullYear(); 
  5.                // curr_month = d.getMonth();
  6.  
  7.                 for(i = 0; i < 2; i++) 
  8.                 { 
  9.                     document.getElementById('year').options[i] = new Option(curr_year-i,curr_year-i); 
  10.  
  11.                    // document.month.option[curr_month].selected=true;
  12.  
  13.                 } 
  14.  
  15.             } 
This gives me dynamic year(upto current year)..
But as soon as I add the commented code
Expand|Select|Wrap|Line Numbers
  1. // curr_month = d.getMonth();
  2.  // document.month.option[curr_month].selected=true;
It fails...
I need date as follows:
If year is 2012 & month is june then list should show 201206

Now current month is june so it should show...201306,2 01305,201304,.. .....,201212,20 1211,201210,... ...& so on..

Can any one help?
Jun 10 '13 #1
17 4503
Dormilich
8,658 Recognized Expert Moderator Expert
Can any one help?
help with what? you didn’t tell what the code actually does and how it is different from what you expect.

anyways, you should take a look at the Error Console, to check whether there are any JS errors listed.
Jun 10 '13 #2
Shepard
24 New Member
@Dormilich..Tha nks for the response..

It does not give any errors.. It simply displays year only...upto current year.. Month is not at all displayed..
I want it as yyyymm==201206. .
Jun 10 '13 #3
Dormilich
8,658 Recognized Expert Moderator Expert
isn’t month in a separate <select>?
Jun 10 '13 #4
Shepard
24 New Member
No month should come in the same select as the year...and should come after year
Jun 10 '13 #5
Dormilich
8,658 Recognized Expert Moderator Expert
No month should come in the same select as the year
and why do you address the month and year differently, then?
Jun 10 '13 #6
Shepard
24 New Member
The problem is it does not display month.. It only displays year..
Also right now year is displayed only once...In the desired output year should be displayed as many times the month currently is...
What changes should I make in the code to get my desired output?
@Dormilich::
and why do you address the month and year differently, then?
How else should I address it?
Jun 10 '13 #7
Dormilich
8,658 Recognized Expert Moderator Expert
How else should I address it?
you said, they were the same <select>, so why should you address them differently?
Jun 10 '13 #8
Shepard
24 New Member
If I use this code
Expand|Select|Wrap|Line Numbers
  1. function populateYearSelect() 
  2.             { 
  3.                 d = new Date(); 
  4.                 curr_year = d.getFullYear(); 
  5.  
  6.                 for(i = 0; i < 2; i++) 
  7.                     document.getElementById('year').options[i] = new Option(curr_year-i,curr_year-i); 
  8.  
  9.                            } 
  10.  
It gives me years upto 2013(current year)...
Now how do I make it show month no. along with the year.. the methods I am trying is not working...
Do you know how can I get desired answer?
Jun 10 '13 #9
Dormilich
8,658 Recognized Expert Moderator Expert
hm, maybe like new Option(""+year+ month, ""+year+mon th)?
Jun 10 '13 #10

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

Similar topics

8
10225
by: Lisa | last post by:
I have a drop down that defaults to "select" after the page refreshes. How do I keep the selected value in the dropdown field... I've tried EVERYTHING and nothing works! :( <script LANGUAGE="JavaScript"> function getServer(form){ var cdoServerName = document.frmSoftware.cdoServerName.options.value;
5
2969
by: Ganco | last post by:
We have a dropdown combobox, where some of the text is wider than the textarea. I cannot set the width of the SELECT any higher due to design restrictions on the company website. When clicking the dropdown box, I want the textarea (which unfolds beneath the dropdown) to expand to the widest element of the options. I can see that Netscape does this automatically, but how would you do it in IE?
4
29529
by: Dabbler | last post by:
I have two tables I'm editing in a Gridview. The VANS table contains a key to the other LESSOR table. I would like to use a dropdown list to select the LessorId value while displaying the Lessor table's "Company" field as text. When I commit the edit I get error:Must declare the scalar variable "@LessorId". Also as a bonus question ;) I don't know how to set the selectedindex value in the dropdown list based on the LessorId value in the...
0
2906
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string strDataValueField; string strDataTextField; public CreateEditItemTemplateDDL(string DDLName,string DataValueField,string
2
1588
by: SF | last post by:
Hi, I am new to ASP.NET. I have started to create a new ASP.NET web. I can succesfully insert a table into a form but my form does not look good becuase some filed (from table) are foreigh key that link to other table to lookup for information and it is displaying only number. I want to change that fields into combo/dropdown field but do not khow how. In Access, in can right click on specific field and change to combo/dropdown on the...
0
1033
by: premkutuva | last post by:
I have created a run time dropdown control in the serverside ASPX file also, i want to creat event handle for that control also i need to handle the OnItemChange( ) event. in server side aspx file, how it can able to do.. pls guid me
1
2702
by: SunshineInTheRain | last post by:
The following code is dynamic create dropdownmenu which data within pulled from database However, the code work well on IE but not on Firefox. On Firefox, the whole mouseover and mouseout function din't work. what is not supported on Firefox? the javascript syntax? please help as i am not familiar with javascript. thanks in advanced. this is quite urgent.... please.. By the way hope there has somebody may help me find out why the design may...
4
2802
by: mainul05 | last post by:
hi, i m newbie php+mysql. in i have the following problem. i tried my best to solve it but could do it. please help me. i have a from where 3 fields are STATE, AREA and SUBRUB. AREA is connected with STATE and SUBRUB is connected with AREA. when a person will select a STATE the corresponding AREA will be available in dropdown box. and when a AREA is selected the corresponding SUBRUB will be available in a dropdown box. please help me with...
8
2314
by: klbrownie | last post by:
I am trying to create a report that asks the user to select the report option from a drop down field. The field is based on field in a form, which pulls its options from a table. Source Table - tblDelayReasons - contains 8 reasons Form - frmMain Table - users select reason using combo box while entering data into form Field in Form - Reason if Procedure Delayed I want the report to ask user to select from same list of reasons. I...
0
8390
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
8911
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...
1
8597
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
8667
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4222
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
2808
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
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1806
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.