473,396 Members | 1,702 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.

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 2869
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
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.