473,241 Members | 1,508 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,241 software developers and data experts.

Cannot Read Value from Drop Down Script

Dan
This is one that has me stumped and I need an expert's input.

Any ideas why the values from the second script-generated drop down
list isn't recognized by the script to add time values to the text
boxes?

What this script is suppose to do is change the value of a second drop
down list based on the selection from the first.

Then a value is chosen from the script generated drop down list in the
second box.

This second drop down box value then runs a script that fills in the
blanks of 2 text fields with 2 different values based on the selection
from the second drop down box.

It works except the value selected in the second drop down box is not
recognized by the script to populate the 2 text fields.

I have manually added them to the second drop down box. If they are
chosen before the first drop down box scipt is run it works fine.

But if they are selected after running the first drop down box script,
the script that adds the value to the text fields views it as empty.


<SCRIPT LANGUAGE="JavaScript">

var firstArray = new Array("('Select one','',true,true)",
"('first')",
"('second')",
"('third')");

var secondArray = new Array("('Select two','',true,true)",
"('fourth')",
"('fifth')",
"('sixth')");

function populateLocation(inForm,selected) {
var selectedArray = eval(selected + "Array");

for (var i=0; i < selectedArray.length; i++) {
eval("inForm.location.options[i]=" + "new Option" + selectedArray[i]);
}
}
</script>

<script type="text/javascript">
function addTimes(a,b,c) {
if (a.value != '') {
/* Validate input here to check time entered is
of correct hh:mm format and within required range
Handle error if is isn't
*/
}
var t0 = a.value.split(':');
var t1 = b.value.split(':');
var t2 = c.value.split(':');

var m1 = +t0[1] + +t1[1];
var h1 = +t0[0] + +t1[0] + Math.floor(m1/60);
m1 = (m1 % 60);
b.value = h1 + ':' + m1;

var m2 = +t0[1] + +t2[1];
var h2 = +t0[0] + +t2[0] + Math.floor(m2/60);
m2 = (m2 % 60);
c.value = h2 + ':' + m2;
}
</script>


<script language="JavaScript">
<!--

function Trip_Time(loc) {
if (document.loc.location.value == "first") {
document.loc.time1.value = "4:30";
document.loc.time2.value = "9:00"; }

else if (document.loc.location.value == "second") {
document.loc.time1.value = "2:40";
document.loc.time2.value = "7:10"; }

else if (document.loc.location.value == "third") {
document.loc.time1.value = "1:10";
document.loc.time2.value = "6:30"; }

else if (document.loc.location.value == "fourth") {
document.loc.time1.value = "3:50";
document.loc.time2.value = "2:10"; }

else if (document.loc.location.value == "fifth") {
document.loc.time1.value = "7:20";
document.loc.time2.value = "11:10"; }

else if (document.loc.location.value == "sixth") {
document.loc.time1.value = "24:00";
document.loc.time2.value = "19:30"; }

else {
document.loc.time1.value = "0:00";

document.loc.time2.value = "0:00";

}
}

// -->
</SCRIPT>

</head>

<body>

<form method="POST" action="results.asp" name="loc">

<select name="region"
onChange="populateLocation(document.loc,document.l oc.region.options[document.loc.region.selectedIndex].value)">
<option selected value=''>Select Region</option>
<option value='first'>First set</option>
<option value='second'>Second set</option>
<option value='third'>third</option>
<option value='fourth'>fourth</option>
<option value='fifth'>fifth</option>
</select>

<br>

<select name="location" onChange="Trip_Time()">
<option value=''>Choose Region 1st</option>
<option value='first'>first</option>
<option value='second'>second</option>
<option value='third'>third</option>
<option value='fourth'>fourth</option>
<option value='fifth'>fifth</option>
</select>
<br>


<label for="inTime">
<input type="text" name="inTime"
onblur="addTimes(this,this.form.time1,
this.form.time2)"></label>
<br>
<label for="inTime">

<input type="text" name="time1"></label>

<br>
<label for="inTime"><input type="text" name="time2"></label>
<br>
<input type="submit" value="Submit" name="B1"> <input type="reset"
value="Reset" name="B2">

</form>
Jul 23 '05 #1
1 2861
In article <29**************************@posting.google.com >,
do****@rocketmail.com enlightened us with...
This is one that has me stumped and I need an expert's input.

Any ideas why the values from the second script-generated drop down
list isn't recognized by the script to add time values to the text
boxes?


What's with all the evals and stuff?

This is my script for doing dynamic select boxes. Check it out.
http://www.ipwebdesign.net/kaelisSpa...icSelects.html

--
--
~kaeli~
Never argue with an idiot! People may not be able to tell
you apart.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2

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

Similar topics

2
by: Xerxes | last post by:
Hi, how can I pass the returned value from Javascript to PHP? I have: ------------------------------------------------------------------------ ------ if ( x>y) {
5
by: BashiraInTrouble | last post by:
Hi Friends, I have tried almost everything but I cant seem to shrink the transaction log. Executing DBCC SQLPERF(LOGSPACE) gives me this info: Database Log Size (MB) Log Space Used (%) ...
0
by: LU | last post by:
I have a datagrid for viewing and deleting. Under that I have a drop down with binded info and a button to add the select drop down item into database. 1User can view datagrid and delete info....
2
by: joltman | last post by:
OK, this is kind of hard to explain, so I'll do my best: I have a form where I have a row where there could be multiple entries, so I have a link where it will dynamically add another row like it,...
2
by: rk330 | last post by:
Greetings I have a drop down list populated by my sql server database. The data on this ASP page consists of numbers that I use to calculate a grand total. This is performed by a javascript...
0
by: weiwei | last post by:
Hi here is my scenario, I create a drop down list in itemtemplate.(that drop down is created from db), after user click edit command, my ideal plan is have another drop down list in...
4
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my...
15
by: ajos | last post by:
Hello all, Im making a dependent drop down for my application for filtering purpose. I have populated the drop down from the database and retrieved in the html. <tr> <td valign="top"...
4
by: phpmagesh | last post by:
Hi I am using php and smarty, what i have to do is i have a drop down box with dynamic name, id and values. like <select name="id" id="id" onchange="sample()" > {foreach key=key_data...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.