473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Two (pulldown) lists

Hi,

In my form I want people to be able to select a startingpoint (month)
and then an endingpoint (month). I can make one list with all te
possible months, and another with again all possible months, but in
that way it is possible to select (i.e.) from june2003 to
february2003.

To make that (reverse) selection impossible, the options in the second
list should change when the user selects a month in the first list.

Example:

First list (From): (last month is automaticly deleted by cgi-script)
January
February
March
April
May

Second list (To): (first month is automaticly deleted by cgi-script)
February
March
April
May
June

The user selects 'March' in the first list.
The only options in the second list should be:
April
May
June

Can anyone tell me how to do this? I think a javascript would be best
for this...
PS If neccessary, the cgi-script to delete the first month of the
second list is ajustable.

The code I have now:

From:
<select name="form_period_begin" id="form_period_begin">
<option value='101>2003' selected>jan03</option>
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
</select><br>

To:
<select name="form_period_end" id="form_period_end">
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
<option value='106>2003' selected>jun03</option>
</select>
Jul 20 '05 #1
4 1463
Look up 'new option' and a related post called 'simple HTML issue' it may
help.
You may need to null 2nd drop down and create new options for the remaining
months.

Stu

"Francois" <go****@francoissachs.nl> wrote in message
news:16*************************@posting.google.co m...
Hi,

In my form I want people to be able to select a startingpoint (month)
and then an endingpoint (month). I can make one list with all te
possible months, and another with again all possible months, but in
that way it is possible to select (i.e.) from june2003 to
february2003.

To make that (reverse) selection impossible, the options in the second
list should change when the user selects a month in the first list.

Example:

First list (From): (last month is automaticly deleted by cgi-script)
January
February
March
April
May

Second list (To): (first month is automaticly deleted by cgi-script)
February
March
April
May
June

The user selects 'March' in the first list.
The only options in the second list should be:
April
May
June

Can anyone tell me how to do this? I think a javascript would be best
for this...
PS If neccessary, the cgi-script to delete the first month of the
second list is ajustable.

The code I have now:

From:
<select name="form_period_begin" id="form_period_begin">
<option value='101>2003' selected>jan03</option>
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
</select><br>

To:
<select name="form_period_end" id="form_period_end">
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
<option value='106>2003' selected>jun03</option>
</select>

Jul 20 '05 #2
With help from some postings and some sites I made this script.
Anyone can improve this?

<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript">
var JSmaanden = new Array("jan03","feb03","mrt03","apr03","mei03","jun 03");
var JSdatums = new
Array("101>2003","102>2003","103>2003","104>2003", "105>2003","106>2003");

function selecter(){
document.formulier.form_periode_eind.selectedIndex =
document.formulier.form_periode_eind.options.lengt h-1;
}

function changelist2(begin) {
document.formulier.form_periode_eind.options.lengt h = 0;
beginmaand = begin.options[begin.selectedIndex].value
mstatus="inactive";
for (i=0; i<JSmaanden.length; i++) {
if (mstatus == "active") {
document.formulier.form_periode_eind.add(new Option(JSmaanden[i],
JSdatums[i]));
}
if (JSdatums[i] == beginmaand) {
mstatus = "active";
}
}
selecter();
}
</script>
</head>

<body onLoad="selecter();">
<form name="formulier" id="formulier">

From:
<select name="form_periode_begin" id="form_periode_begin"
onChange="changelist2(this)">
<option value='101>2003'>jan03</option>
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrt03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>mei03</option>
</select><br>

To:
<select name="form_periode_eind" id="form_periode_eind" >
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>mei03</option>
<option value='106>2003'>jun03</option>
</select>
</form>
</body>
</html>
"Stuart Palmer" <tr**********@youcant.com> wrote
Look up 'new option' and a related post called 'simple HTML issue' it may
help.
You may need to null 2nd drop down and create new options for the remaining months.

Stu

"Francois" <go****@francoissachs.nl> wrote
Hi,

In my form I want people to be able to select a startingpoint (month)
and then an endingpoint (month). I can make one list with all te
possible months, and another with again all possible months, but in
that way it is possible to select (i.e.) from june2003 to
february2003.

To make that (reverse) selection impossible, the options in the second
list should change when the user selects a month in the first list.

Example:

First list (From): (last month is automaticly deleted by cgi-script)
January
February
March
April
May

Second list (To): (first month is automaticly deleted by cgi-script)
February
March
April
May
June

The user selects 'March' in the first list.
The only options in the second list should be:
April
May
June

Can anyone tell me how to do this? I think a javascript would be best
for this...
PS If neccessary, the cgi-script to delete the first month of the
second list is ajustable.

The code I have now:

From:
<select name="form_period_begin" id="form_period_begin">
<option value='101>2003' selected>jan03</option>
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
</select><br>

To:
<select name="form_period_end" id="form_period_end">
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
<option value='106>2003' selected>jun03</option>
</select>


Jul 20 '05 #3
Oz
There is rather simple way to do this since both options lists are
identical:

function restrict(start){
//get the starting options
var options = start.options;
//get the index of the month selected
var index = start.selectedIndex;
//clear the end options
var end = document.getElementById("form_period_end");
end.innerHTML = "";
//clone the moths after the selected month and append to the end select
for (var i=index;i<options.length;i++) {
var newOption = options[i].cloneNode(true);
end.appendChild(newOption);
}

}

</script>

<select name="form_period_begin" id="form_period_begin"
onchange="restrict(this)">
<option value='101>2003' selected>jan03</option>
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
</select><br>
<select name="form_period_end" id="form_period_end">
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
<option value='106>2003' selected>jun03</option>
</select>


"Francois" <go****@francoissachs.nl> wrote in message
news:16*************************@posting.google.co m...
Hi,

In my form I want people to be able to select a startingpoint (month)
and then an endingpoint (month). I can make one list with all te
possible months, and another with again all possible months, but in
that way it is possible to select (i.e.) from june2003 to
february2003.

To make that (reverse) selection impossible, the options in the second
list should change when the user selects a month in the first list.

Example:

First list (From): (last month is automaticly deleted by cgi-script)
January
February
March
April
May

Second list (To): (first month is automaticly deleted by cgi-script)
February
March
April
May
June

The user selects 'March' in the first list.
The only options in the second list should be:
April
May
June

Can anyone tell me how to do this? I think a javascript would be best
for this...
PS If neccessary, the cgi-script to delete the first month of the
second list is ajustable.

The code I have now:

From:
<select name="form_period_begin" id="form_period_begin">
<option value='101>2003' selected>jan03</option>
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
</select><br>

To:
<select name="form_period_end" id="form_period_end">
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
<option value='106>2003' selected>jun03</option>
</select>

Jul 20 '05 #4
Good job for IE, but don't forget to test in NS...

"Francois" <fr************@gidesign.nl> wrote in message
news:3f*********************@news.inter.NL.net...
With help from some postings and some sites I made this script.
Anyone can improve this?

<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript">
var JSmaanden = new Array("jan03","feb03","mrt03","apr03","mei03","jun 03"); var JSdatums = new
Array("101>2003","102>2003","103>2003","104>2003", "105>2003","106>2003");

function selecter(){
document.formulier.form_periode_eind.selectedIndex =
document.formulier.form_periode_eind.options.lengt h-1;
}

function changelist2(begin) {
document.formulier.form_periode_eind.options.lengt h = 0;
beginmaand = begin.options[begin.selectedIndex].value
mstatus="inactive";
for (i=0; i<JSmaanden.length; i++) {
if (mstatus == "active") {
document.formulier.form_periode_eind.add(new Option(JSmaanden[i],
JSdatums[i]));
}
if (JSdatums[i] == beginmaand) {
mstatus = "active";
}
}
selecter();
}
</script>
</head>

<body onLoad="selecter();">
<form name="formulier" id="formulier">

From:
<select name="form_periode_begin" id="form_periode_begin"
onChange="changelist2(this)">
<option value='101>2003'>jan03</option>
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrt03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>mei03</option>
</select><br>

To:
<select name="form_periode_eind" id="form_periode_eind" >
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>mei03</option>
<option value='106>2003'>jun03</option>
</select>
</form>
</body>
</html>
"Stuart Palmer" <tr**********@youcant.com> wrote
Look up 'new option' and a related post called 'simple HTML issue' it may help.
You may need to null 2nd drop down and create new options for the

remaining
months.

Stu

"Francois" <go****@francoissachs.nl> wrote
Hi,

In my form I want people to be able to select a startingpoint (month)
and then an endingpoint (month). I can make one list with all te
possible months, and another with again all possible months, but in
that way it is possible to select (i.e.) from june2003 to
february2003.

To make that (reverse) selection impossible, the options in the second
list should change when the user selects a month in the first list.

Example:

First list (From): (last month is automaticly deleted by cgi-script)
January
February
March
April
May

Second list (To): (first month is automaticly deleted by cgi-script)
February
March
April
May
June

The user selects 'March' in the first list.
The only options in the second list should be:
April
May
June

Can anyone tell me how to do this? I think a javascript would be best
for this...
PS If neccessary, the cgi-script to delete the first month of the
second list is ajustable.

The code I have now:

From:
<select name="form_period_begin" id="form_period_begin">
<option value='101>2003' selected>jan03</option>
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
</select><br>

To:
<select name="form_period_end" id="form_period_end">
<option value='102>2003'>feb03</option>
<option value='103>2003'>mrc03</option>
<option value='104>2003'>apr03</option>
<option value='105>2003'>may03</option>
<option value='106>2003' selected>jun03</option>
</select>



Jul 20 '05 #5

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

Similar topics

3
by: R.G. Vervoort | last post by:
I would like to select an option in a pulldown, select a record in a mysql database depending on the pulldown selection and then put the data from the record in the textfields. I can retrieve...
1
by: cgplays.com | last post by:
Are there any good places to look for asp.net modules for select pulldowns? There is a select pulldown on a site i do partial development on http://www.computergroupplays.com/fb-pres4.asp that has...
7
by: jason | last post by:
Is there a way - possibly a disconnected rs? - to update the contents of an existing pulldown on a page without having to re-submit the page for the user to see the pulldown populated with an...
3
by: Mark R | last post by:
I have one .asp page with a SELECT pulldown list on it and some INPUT fields. When SUBMIT is clicked the form data is submitted to that same page and validated. If INPUT fields are empty the asp...
1
by: cgplays.com | last post by:
I have a select-pulldown at http://computergroupplays.com/fb-pres2.asp that changes the 3rd pulldown (Dbase) depending on what the user enters in the 2nd (Wk). My associate wants the values inside...
2
by: Oskar Wild | last post by:
Hello, how do I code it to display a select (pulldown) box only if the user has selected a certain option in another pulldown box? <select name=country> <OPTION value="France" SELECTED>France...
9
by: flarkblark | last post by:
I recently had the displeasure of looking at the code required to implement the pop-up menus used in a pulldown menu system for a webpage. The sheer amount of Javascript required was amazing...
4
by: Richard MSL | last post by:
I am making a combobox, where I add items to the combobox as they are required, as the user scrolls to the top or bottom of the list of items. It is a sorted combobox. Scrolling down works fine,...
20
by: Highlander | last post by:
Hello all. Consider the following HTA: <html> <head> <title>Date Pulldowns</title> <HTA:APPLICATION ID="HTAUI" APPLICATIONNAME="Date Pulldowns" SCROLL="no" SINGLEINSTANCE="yes"
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.