473,592 Members | 2,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dropdown box change index to matching

Hi, i ma trying to change a dropdown box index to mathing value of on
another dropdown box in same form. here is the form

--------------------------------------------------------------------------------------------------------------------------
<form method="post" name="myform" action="default .asp">
<p>
Select Month:
<select name="mymonth"
onChange="docum ent.getElementB yId('myday').se lectedIndex=0">
<option value="20080401 " selected="selec ted" >April-2008 (26158)</option>
<option value="20080301 " >March-2008 (2)</option>
<option value="20080201 " >February-2008 (1)</option>
</select>

Day:
<select name="myday" >
<option value="0" >All days</option>
<option value="20080401 " >1-Tuesday (1)</option>
<option value="20080420 " >20-Sunday (2)</option>
<option value="20080421 " >21-Monday (1)</option>
<option value="20080425 " selected="selec ted">25-Friday (26154)</option>
</select>
<input type="submit" value="View"/>
</p>
</form>
-------------------------------------------------------------------------------------------------------------------------------------------
when mymonth changes scipt sets myday seleceted index to 0 (ALL days)
and hits submits, data from that month comes but user can first select month
then change day on myday selectbox and hit submit. that would bring wrong
data. so i am trying to prevent that
by changing mymonth data to matching value of myday onchange vent on myday

mymnth value always unique and myday data always incremental (as in
20080401,200804 02,20080403)
you would notice myday value has 2 more characters than mymonth data but to
sort this problem out i've got below function

-------------------------------------------------------
function Left(str, n)
{
if (n <= 0) // Invalid bound, return blank string
return "";
else if (n String(str).len gth) // Invalid bound, return
return str; // entire string
else // Valid bound, return appropriate substring
return String(str).sub string(0,n);
}
--------------------------------------------------------------------------------------------------

so, how can i do it?
select name="myday"
onChange="docum ent.getElementB yId('mymonth'). selectedIndex=? ??????????????? ??????????????? ??">

can anyone give me a clue?

thanks
Jun 27 '08 #1
1 1805
.nLL wrote:
Hi, i ma trying to change a dropdown box index to mathing value of on
another dropdown box in same form. here is the form

--------------------------------------------------------------------
<form method="post" name="myform" action="default .asp">
<p>
Select Month:
<select name="mymonth"
onChange="docum ent.getElementB yId('myday').se lectedIndex=0">
'myday' is a name-attribute, not an ID.
<option value="20080401 " selected="selec ted" >April-2008 (26158)</option>
Must be:
<option value="20080401 " selected>April-2008 (26158)</option>
<option value="20080301 " *>March-2008 (2)</option>
<option value="20080201 " *>February-2008 (1)</option>
</select>

Day:
<select name="myday" >
<option value="0" >All days</option>
<option value="20080401 " >1-Tuesday (1)</option>
<option value="20080420 " >20-Sunday (2)</option>
<option value="20080421 " >21-Monday (1)</option>
<option value="20080425 " selected="selec ted">25-Friday (26154)</option>
</select>
<input type="submit" value="View"/>
</p>
</form>
--------------------------------------------------------------------
when mymonth changes scipt sets myday seleceted index to *0 (ALL days)
and hits submits, data from that month comes but user can first select month
then change day on myday selectbox and hit submit. that would bring wrong
data. so i am trying to prevent that
by changing mymonth data to matching value of myday onchange vent on myday

mymnth value always unique and myday data always incremental (as in
20080401,200804 02,20080403)
[...]

I think you actually don't need any javascript. The selected date is
all the server asks; it could easily strip the month from that if need
be.

<select name="myday">
<option value="20080428 ">Monday, April 28 2008</option>
<option value="20080509 ">Friday, May 9 2008</option>
<option value="20080524 ">Saturday, May 24 2008</option>
<option value="20080608 ">Sunday, June 8 2008</option>
</select>
<input type="submit">

...does exactly the same and is much more efficient design.

If you want two boxes anyhow, here is a fine example:
http://www.javascripttoolbox.com/lib/dynamicoptionlist/

Hope this helps,

--
Bart
Jun 27 '08 #2

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

Similar topics

1
4746
by: Hermes | last post by:
Hi All, I've tried searching for this answer but have had no joy. Is there anyway with javascript to allow the end user to click in a dropdown box and when they type the first few letters it brings up the next match rather than the first bunch of words with the last letter. e.g. Dropdown box : BIRMINGHAM
3
1491
by: usenet | last post by:
Hi. If I have an index (or primary key) on 3 columns, will a subset of these columns automatically be indexed also? For example: CREATE INDEX idx ON tbl(cola, colb, colc); Will: SELECT cold FROM tbl WHERE cola = 1 AND colb = 2
4
1980
by: Doslil | last post by:
I have a form which has a subform.In the main form I have only one field (this is a drop down list and has a query attached to it) which selects empno,Name from the EmployeeInformation table. The sub form stores the time sheet data for each employee.When I am able to do the timesheet data entry for the first record.But when I select the second employee from the dropdown list and click on the subform for entering the timesheet data, it...
2
4541
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
0
2903
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
3
1668
by: | last post by:
I have a Datagrid and it has a dropdown. <asp:DropDownList DataSource="<%# PopulateList() %>" OnLoad="SelectIndex" > I assign selected index of the my dropdown in SelectIndex function. protected void SelectIndex(object source, System.EventArgs e) { DropDownList DXmlFirmalar = (DropDownList)source;
11
7376
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and the Dropdown doesnt have any items.. The requirement is that as soon as one goes on typing the letters in the StudentName-textbox the corresponding matching names have to appear
4
2102
by: in da club | last post by:
I have a datagrid and a dropdown in my page. I want to fill dropdown with my pagenumbers. When a user change the dropdown selected index i wnt to display the result on label1. Anytime i change the dropdown index it returns zero .. What is the problem ? private void Page_Load(object sender, System.EventArgs e) { int TotalP=0;
5
21001
by: Kalkin | last post by:
Hi Is it possible to change the data source of a dropdown list in a gridview from another dropdown list selected index changed method in the same gridview? for example I have a dropdown that needs to change its contents depending on what is chosen in the previous cell of the gridview, which is also a dropdown list. Any Help would be much appreciated Thanks
0
7935
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7871
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
8366
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
7995
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
8227
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...
0
6642
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3851
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
2379
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
1
1467
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.