Dear All,
I am a learner of Javascript. I got an assignment as below. Could anyone give me a suggestion for fixing the function of "onChangeColumn 4()".
The original requirement of the start date of this practice is 1985 09 20.
When user click different year and different month, then the "Index Number" will display different number. (actually, every season is the same index number".)
I used a data hierarchy approach to program it, but it seems not working very well.
If anyone can give me suggestion, I deeply appreciate.
Best Wishes!
Aleck
-----------------------------------------------------------------------
[HTML]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>test</title>
<style type="text/css">
<!--
body {
background-color: #CCCCCC;
}
.style3 {
font-size: 24px;
font-weight: bold;
}
.style4 {
color: #660000;
font-size: 16px;
font-weight: bold;
text-decoration: none;
}
-->
</style>
<script>
function node(name, child){
this.name=name;
this.child=chil d;
}
function dataHierarchy() {
// before 1985
var b1985=new Array();
var i=0;
b1985[i++]=new node(" ", [" "]);
// 1985
var y1985=new Array();
var i=0;
y1985[i++]=new node(" ", [" "]);
y1985[i++]=new node("09", [" 71.3"]);
y1985[i++]=new node("10", [" 72.7"]);
y1985[i++]=new node("11", [" 72.7"]);
y1985[i++]=new node("12", [" 72.7"]);
// 1986
var y1986=new Array();
var i=0;
y1986[i++]=new node(" ", [" "]);
y1986[i++]=new node("01", [" 74.4"]);
y1986[i++]=new node("02", [" 74.4"]);
y1986[i++]=new node("03", [" 74.4"]);
y1986[i++]=new node("04", [" 75.6"]);
y1986[i++]=new node("05", [" 75.6"]);
y1986[i++]=new node("06", [" 75.6"]);
y1986[i++]=new node("07", [" 77.6"]);
y1986[i++]=new node("08", [" 77.6"]);
y1986[i++]=new node("09", [" 77.6"]);
y1986[i++]=new node("10", [" 79.8"]);
y1986[i++]=new node("11", [" 79.8"]);
y1986[i++]=new node("12", [" 79.8"]);
// year
var output=new Array();
var i=0;
output[i++]=new node(" ", b1985);
output[i++]=new node("1985", y1985);
output[i++]=new node("1986", y1986);
return(output);
}
dataTree=dataHi erarchy();
//
function onChangeColumn3 (){
updatePath();
}
//
function onChangeColumn2 (){
form=document.t heForm;
index1=form.col umn1.selectedIn dex;
index2=form.col umn2.selectedIn dex;
index3=form.col umn3.selectedIn dex;
// Create options for column 3
for (i=0;i<dataTree[index1].child[index2].child.length;i ++)
form.column3.op tions[i]=new Option(dataTree[index1].child[index2].child[i], dataTree[index1].child[index2].child[i]);
form.column3.op tions.length=da taTree[index1].child[index2].child.length;
form.column4.va lue="";
updatePath();
}
//
function onChangeColumn1 () {
form=document.t heForm;
index1=form.col umn1.selectedIn dex;
index2=form.col umn2.selectedIn dex;
index3=form.col umn3.selectedIn dex;
// Create options for column 2
for (i=0;i<dataTree[index1].child.length;i ++)
form.column2.op tions[i]=new Option(dataTree[index1].child[i].name, dataTree[index1].child[i].name);
form.column2.op tions.length=da taTree[index1].child.length;
// Clear column 3
form.column3.op tions.length=0;
form.column4.va lue="";
updatePath();
}
//
function updatePath(){
form=document.t heForm;
index1=form.col umn1.selectedIn dex;
index2=form.col umn2.selectedIn dex;
index3=form.col umn3.selectedIn dex;
if ((index1>=0) && (index2>=0) && (index3>=0)) {
text1=form.colu mn1.options[index1].text;
text2=form.colu mn2.options[index2].text;
text3=form.colu mn3.options[index3].text;
form.path.value =text1+" ==> "+text2+" ==> "+text3;
} else
form.path.value ="";
}
function onChangeColumn4 (){
node ();
dataHierarchy() ;
form=document.t heForm;
index1=form.col umn1.selectedIn dex;
index2=form.col umn2.selectedIn dex;
if ((index2 == "09") && (index1 == "1985"))
{
for (var d=20; d <=30; d++)
document.writel n("<option value=" + d + ">" + d + "</option>");
}
else {
for (var d=1; d <=31; d++)
document.writel n("<option value=" + d + ">" + d + "</option>");
}
}
</script>
</head>
<body>
<table width="94%" border="0" align="center">
<tr>
<td colspan="2">
<p> </p>
<p> </p>
</td>
</tr>
<tr>
<td colspan="2">
<form id="theForm" name="theForm" method="post" action="">
<table width="341" border="0" align="center" cellpadding="3" cellspacing="3" bordercolor="#0 00000">
<tr align="center" bgcolor="lightg rey">
<td width="173" height="25" bgcolor="#99999 9" class="style4">
<div align="center">
<u>Date of Acquisition</u>
</div>
</td>
<td width="147" bgcolor="#99999 9" class="style4">
<div align="center">
<u>Index Number</u>
</div>
</td>
</tr>
<tr bgcolor="white" >
<td>
<div align="center">
<table align=center border=0>
<tr>
<td align=center>
<select name="column1" onChange="onCha ngeColumn1();">
<script>
for (i=0; i<dataTree.leng th; i++)
document.writel n("<option value=\""+dataT ree[i].name+"\">"+dat aTree[i].name);
</script>
</select>
</td>
<td align=center>
<select name="column2" onChange="onCha ngeColumn2();">
</select>
</td>
<td>
<select name="column4">
<option selected="selec ted"> </option>
<script>
onChangeColumn4 ();
</script>
</select>
</td>
<td align=center>
<div align="center"> </div>
</td>
</tr>
</table>
</div>
</td>
<td>
<div align="center">
<select name="column3" size="1" onChange="onCha ngeColumn3();">
</select>
</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>[/HTML]
3 1428 acoder 16,027
Recognized Expert Moderator MVP acoder 16,027
Recognized Expert Moderator MVP
You can't call onChangeColumn4 like that. You will have to call it when one of the other select options onchange fires.
hi dear
if your mean is , you want show the Data of selected day , so why you dont give the actual day Data like it : ?
[HTML]
y1986[i++]=new node("12", ["01"," 79.8"]);
y1986[i++]=new node("12", ["02"," 75.5"]);
y1986[i++]=new node("12", ["03"," 80.3"]);
y1986[i++]=new node("12", ["10"," 71.2"]);
y1986[i++]=new node("12", ["23"," 72.6"]);
y1986[i++]=new node("12", ["30"," 70.8"]);
[/HTML]
best regards.
mh
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: kie |
last post by:
hello,
when i create elements and want to assign events to them, i have
realised that if the function assigned to that element has no
parameters, then the parent node values can be attained.
e.g.
aTextBox=document.createElement('input');
aTextBox.onchange=calculateOneRow2;
|
by: MonkeyBoy |
last post by:
I am doing some some HTML manipulation in client-side script (IE5.x and IE6.x browsers only).
Something like..
var tmpHTML = oTable.outerHTML
// do something to the HTML her
oTable.outerHTML = tmpHTML
Before the changes, client-side .Net field validators (RegularExpressionValidator, RangeValidator, etc.) work fine... after the changes, the modified HTML works correctly but the validators stop functioning. Seems that the onchange handler...
|
by: NewmanBT |
last post by:
As you can see from the code below, several textboxes will be
dynamically created and each will be tied to an org. The
ChangeComment function should allow for an update to the database
whenever the value of the associated textbox changes. However, I'm
having trouble associating the textbox to the org. strOrg is a global
variable which changes throughout the runtime.
How do I capture its value at each stage a textbox is created so that...
|
by: Christoph |
last post by:
I'm trying to validate some HTML form elements when the
user tabs out of each element. However, I'm having some
problems.
It appears that the order of events is onChange followed
some time afterwards by onBlur. I believe this to be the
case because in my onChange script, if the validation fails,
I force focus back to the field element. However, the focus
still falls to the next field and not back to the field I tried to
force the...
|
by: Bart van Deenen |
last post by:
Hi all
I have a script where I dynamically create multiple inputs and selects
from a script. The inputs and selects must have an associated onchange
handler.
I have the script working fine on Firefox, Safari and Konqueror, but the
onchange event just doesn't fire on IE6.
Firefox's javascript console shows no errors, and the IE script debugger
shows nothing. onchange is not triggered.
| |
by: a10392 |
last post by:
Hi,
I'am triyng to create a form where i have 2 comboBox and 2 textbox, when the selection changes on the first combo , the content of second also changes. i have to use onchange=form.submit()
the problem is, i want to have a button to finish the selection and save all the data to a database, but if i have diferent forms, i will not get the last change on the text boxs, only th last change when i changed the combobox.
Using the same...
|
by: Zeebra3 |
last post by:
Here goes: I have a web form with several asp:dropdownlists, with
which, when selection is changed I want to fire an event defined in
some clientside js.
The content of the clientside code is dependant on data collected in
the code behind on the server. I have set AutoPostback to false for
the controls and added lines such as
cboMyCombo1.Attributes.Add("onchange", "MyCombos_OnChange('1')");
in the Page_Load event, which is rendered OK...
|
by: Kathy Burke |
last post by:
Hi, I have a textbox and a calendar popup window. I got this from a
posting (sorry, his name escapes me at the moment). It's nice and
simple, so I like it, of course.
Only problem I have is that when the popup closes and puts the control
value (date selected) into the textbox on my main form, I can't get my
onchnage event to fire (i.e., which should load a datagrid).
This is the sub that the calendar pop-up form uses when the date is...
|
by: kirkgilbert |
last post by:
I am trying to do an onchange event in a form using a text field. The form is tied to a record set that is part of a repeated region. One the first record when I edit the data it works perfectly. When I go to the second record nothing happens. I have attached the code below: I bolded text that contains the javascript and fields this is applied to
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/FutureOrders.asp"...
|
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...
|
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,...
| |
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...
|
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...
|
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();...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |