473,703 Members | 2,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="JavaS cript">

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

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

function populateLocatio n(inForm,select ed) {
var selectedArray = eval(selected + "Array");

for (var i=0; i < selectedArray.l ength; i++) {
eval("inForm.lo cation.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="JavaS cript">
<!--

function Trip_Time(loc) {
if (document.loc.l ocation.value == "first") {
document.loc.ti me1.value = "4:30";
document.loc.ti me2.value = "9:00"; }

else if (document.loc.l ocation.value == "second") {
document.loc.ti me1.value = "2:40";
document.loc.ti me2.value = "7:10"; }

else if (document.loc.l ocation.value == "third") {
document.loc.ti me1.value = "1:10";
document.loc.ti me2.value = "6:30"; }

else if (document.loc.l ocation.value == "fourth") {
document.loc.ti me1.value = "3:50";
document.loc.ti me2.value = "2:10"; }

else if (document.loc.l ocation.value == "fifth") {
document.loc.ti me1.value = "7:20";
document.loc.ti me2.value = "11:10"; }

else if (document.loc.l ocation.value == "sixth") {
document.loc.ti me1.value = "24:00";
document.loc.ti me2.value = "19:30"; }

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

document.loc.ti me2.value = "0:00";

}
}

// -->
</SCRIPT>

</head>

<body>

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

<select name="region"
onChange="popul ateLocation(doc ument.loc,docum ent.loc.region. options[document.loc.re gion.selectedIn dex].value)">
<option selected value=''>Select Region</option>
<option value='first'>F irst set</option>
<option value='second'> Second set</option>
<option value='third'>t hird</option>
<option value='fourth'> fourth</option>
<option value='fifth'>f ifth</option>
</select>

<br>

<select name="location" onChange="Trip_ Time()">
<option value=''>Choose Region 1st</option>
<option value='first'>f irst</option>
<option value='second'> second</option>
<option value='third'>t hird</option>
<option value='fourth'> fourth</option>
<option value='fifth'>f ifth</option>
</select>
<br>


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

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

<br>
<label for="inTime"><i nput 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 2911
In article <29************ **************@ posting.google. com>,
do****@rocketma il.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
3527
by: Xerxes | last post by:
Hi, how can I pass the returned value from Javascript to PHP? I have: ------------------------------------------------------------------------ ------ if ( x>y) {
5
18336
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 (%) Status MY_eems 368.49219 16.034182 0 I made a complete backup of the database and transaction log and then executed this statement: DBCC SHRINKFILE (MYeems_log, 1)
0
3700
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. 2User can select from drop down, click add button and add selection to database. A)Datagrid binds and deletes fine. B)If I select the first value of drop down addition to database works fine. C)<problem>if I select the 2nd value of drop down it...
2
2162
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, and this can happen as many times as you click on the link. This row consists of 2 drop-down boxes. Depending on the selection of the first drop-down box, the second drop-down box is either disabled or enabled. The problem is on these dynamically...
2
7286
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 function. See below... function CalculateGrandTotal(SubTotal, ServiceFee) { var shippingSelect = document.getElementById('shipping'); var shippingRequested = shippingSelect.options.value; var grandTotal = Number(shippingRequested) +...
0
2159
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 edititemtemplate with preselected value from the previous drop down list, so far I can only achieved with the regular drop down list in edititemtemplate with no preselected value from previous one. anyone can help me. thanks in advance. below is my current...
4
8279
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 problems and this one is really getting to me... I have a page that allows you to Browse Authors. There are three drop down boxes that auto-populate via AJAX. I have a file which it calls and returns the dynamically built XML file in the boxes...
15
23291
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" width="138" height="26"><small><font face="Verdana"><strong>Branch</strong></font></small></td> <td width="379" height="26"> <select name="branch" size="1" onChange="messValue()"> <option value="">(select branch)</option> <% ...
4
7021
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 item=item_data from=$options_data.DATA} <option value="{$item_data.ID}">{$item_data.TEXT} {if $item_data.PRICE !='' }{$item_data.PREFIX} {$item_data.PRICE}{/if} </option> {/foreach}
0
9121
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
9017
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
8962
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
7867
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...
1
6588
isladogs
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...
0
5922
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();...
0
4687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3123
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
3
2069
bsmnconsultancy
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...

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.