472,801 Members | 1,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,801 software developers and data experts.

dynamic drop downs

i have 2 drop downs that have months in them such as
1/1/2005 and 1/31/2005

I need to my starting month drop down to be a month behind the end of month

so something like this:
if month ending = 1/31/2006
I need start month = 12/31/2005

how can I do thi? is it possible?
its kind of a backwards thing, but the month end dropdown can be populated
from a querystring so if 1/31/2006 is passed I need to set the start month
to be 12/31/2005
Dec 6 '06 #1
4 1097
Hello Mike,

From your description, you have an ASP.NET page which has two dropdownlists
and they'll display two month values and you want to make one list's
selected month 1 month behind another(start and end), correct?

As for this scenario, I think it is a typical dropdownlist synchornize
issue, I'm wondering how would like to implement the synchronizing between
the two values, use server-side code logic or client-side script?

Generally, most page will use client script to manipulate such cascading
value changes in associated dropdownlists. you can hook the
dropdownlist(<selecthtml element)'s client-side "onchange" event. BTW,
are the months items in each list fixed? For example, both of the list only
contains 12 months(items)? If so, you can even use selectedIndex value to
determine how to adjust each list's selected value.

Please feel free to let me know your detailed scenario and requirement.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 6 '06 #2
If you are doing it server-side you can determine the startDate doing
something like this:

'This is where you would convert your querystring to a datetime object
Dim endDate As DateTime = System.Convert.ToDateTime("1/31/2006")

'startDate will be the last day of the month previous to the endDate
Dim startDate As DateTime =
endDate.AddDays(-endDate.DaysInMonth(endDate.Year, endDate.Month))

You could then select the listbox item that matches the date.

Like Steven said, most people do this on the client-side so that you don't
have to do a post-back to figure out what to select in the dropdown. If you
know JavaScript its not that hard to do.

--
Nick Wegner

"Steven Cheng[MSFT]" wrote:
Hello Mike,

From your description, you have an ASP.NET page which has two dropdownlists
and they'll display two month values and you want to make one list's
selected month 1 month behind another(start and end), correct?

As for this scenario, I think it is a typical dropdownlist synchornize
issue, I'm wondering how would like to implement the synchronizing between
the two values, use server-side code logic or client-side script?

Generally, most page will use client script to manipulate such cascading
value changes in associated dropdownlists. you can hook the
dropdownlist(<selecthtml element)'s client-side "onchange" event. BTW,
are the months items in each list fixed? For example, both of the list only
contains 12 months(items)? If so, you can even use selectedIndex value to
determine how to adjust each list's selected value.

Please feel free to let me know your detailed scenario and requirement.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 6 '06 #3
Mike,

So, did you want to do this client side or server side? Do you still need
help with this?

--
Nick Wegner

"igotyourdotnet" wrote:
Both list are fixed and contain 12 months for the passed 10 years. So they
can have dates from 11/01/2006 back to 1/1/1998.

so if 11/31/2005 is passed as the ending date I need 10/01/2005 as the start
date.
"Steven Cheng[MSFT]" wrote:
Hello Mike,

From your description, you have an ASP.NET page which has two dropdownlists
and they'll display two month values and you want to make one list's
selected month 1 month behind another(start and end), correct?

As for this scenario, I think it is a typical dropdownlist synchornize
issue, I'm wondering how would like to implement the synchronizing between
the two values, use server-side code logic or client-side script?

Generally, most page will use client script to manipulate such cascading
value changes in associated dropdownlists. you can hook the
dropdownlist(<selecthtml element)'s client-side "onchange" event. BTW,
are the months items in each list fixed? For example, both of the list only
contains 12 months(items)? If so, you can even use selectedIndex value to
determine how to adjust each list's selected value.

Please feel free to let me know your detailed scenario and requirement.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Dec 7 '06 #4
Hi Mike,

Here is a simple example page which use pure client-side script to
synchornize the two dropdownlist(<select>), both of them contain 24 months:

===================================
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function sync_lists(source)
{
var lst1 = document.getElementById("lstStart");
var lst2 = document.getElementById("lstEnd");


if(lst1.selectedIndex == lst1.options.length-1)
{
lst1.selectedIndex = lst2.selectedIndex - 1;
}
else if(lst2.selectedIndex == 0)
{
lst2.selectedIndex = lst1.selectedIndex + 1;
}
else
{

if(source == 0)
{
lst2.selectedIndex = lst1.selectedIndex + 1;
}
else
{
lst1.selectedIndex = lst2.selectedIndex - 1;
}
}
}

</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<select id="lstStart" name="lstStart" onchange="sync_lists(0);" >
<option selected="selected" >06-01</option>
<option>06-02</option>
<option>06-03</option>
<option>06-04</option>
<option>06-05</option>
<option>06-06</option>
<option>06-07</option>
<option>06-08</option>
<option>06-09</option>
<option>06-10</option>
<option>06-11</option>
<option>06-12</option>
<option>07-01</option>
<option>07-02</option>
<option>07-03</option>
<option>07-04</option>
<option>07-05</option>
<option>07-06</option>
<option>07-07</option>
<option>07-08</option>
<option>07-09</option>
<option>07-10</option>
<option>07-11</option>
<option>07-12</option>
</select>

<select id="lstEnd" name="lstEnd" onchange="sync_lists(1);">
<option >06-01</option>
<option selected="selected">06-02</option>
<option>06-03</option>
<option>06-04</option>
<option>06-05</option>
<option>06-06</option>
<option>06-07</option>
<option>06-08</option>
<option>06-09</option>
<option>06-10</option>
<option>06-11</option>
<option>06-12</option>
<option>07-01</option>
<option>07-02</option>
<option>07-03</option>
<option>07-04</option>
<option>07-05</option>
<option>07-06</option>
<option>07-07</option>
<option>07-08</option>
<option>07-09</option>
<option>07-10</option>
<option>07-11</option>
<option>07-12</option>
</select>
</div>
</form>
</body>
</html>
======================================

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: Kingdom | last post by:
In my data base I have a list of componet types e.g. type A - I have 8 off - type B I have 12 off etc. I'm using Set objRS = objDC.Execute("Select DISTINCT Component_Type FROM Parts_Table") ...
3
by: CSharpguy | last post by:
I have 3 drop downs that are populated from the databasem 4 of my web pages need to have this drop down, how can I trap the selection made in the drop down and popuate my grid on my form?
1
by: Jeff Gardner | last post by:
Greetings: I have a table with 3 pieces of data that I would like to use to dynamically populate 3 drop downs using javascript. The fields are state, orgname, office. If it's not already...
0
by: Steve Funk | last post by:
All, I have searched all around and have not yet found the answer to this nor a solution. Hopfully it will be easy to overcome. Here is what I am trying to do: I'm trying to build a wizard...
1
by: MiG | last post by:
Hello all, I want to make a dynamic 4 drop down menus with AJAX and PHP/mySQL, like this: Category->dynamic subCategory County->dynamic cityCounty Is there any good tutorial that can...
1
by: JackInDaBox | last post by:
Hello, I am new to this and have run into a small problem. I am using the Ajax toolkit with VS 2005 to fill some drop downs through a web service and it works great. All of the cascading drop...
4
by: phub11 | last post by:
Hi, I've found a great website which can extract data from a MySQL database and populate chained drop downs. (http://www.noboxmedia.com/20/massive-ajax-countryarea-drop-down-list/) I'd like the...
14
by: maya | last post by:
hi, I need help with a dynamic nav menu, http://www.mayacove.com/design/nav/nav.html it looks like I want it in IE 7, but in FF and IE 6 it's totally messed up.. in FF the main-nav section...
4
by: audreyality | last post by:
I am new to javascript and appreciate any guidance on this issue, so thank you in advance for your advice! Situation: I am working with a form that will send information to a database. I need the...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

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.