docean@rocketmail.com (Dan) wrote in message news:<296dd184.0411281502.1d8fa71b@posting.google. com>...[color=blue]
> I'm making some progress.
>
> I can't seem to get this to take more than 1 variable. High_Way2 will
> not pass on its time value.
>
> Anyone see any glaring errors?
>
> Thanks again for all the help.
>
> <script language="JavaScript">
> <!--
>
> function Trip_Time(Traffic_Results) {
> if (document.Traffic_Results.CIP_Diff.value == "High_Way1") {
> document.Traffic_Results.display_time.value = "2:20";
>
> if (document.Traffic_Results.CIP_Diff.value == "High_Way1") {
> document.Traffic_Results.display_time2.value = "4:30";
>
> if (document.Traffic_Results.CIP_Diff.value == "High_Way2") {
> document.Traffic_Results.display_time.value = "2:20";
>
> if (document.Traffic_Results.CIP_Diff.value == "High_Way2") {
> document.Traffic_Results.display_time2.value = "4:30";
>
> }
>
> }
> }
>
> }
> else {
> document.Traffic_Results.display_time.value = "0:00";
>
> document.Traffic_Results.display_time2.value = "0:00";
>
> }
> }
>
> // -->
> </SCRIPT>
> </HEAD>
>
> <BODY BGCOLOR="white">
>
> <form name="Traffic_Results">
>
>
> <select name="CIP_Diff" onChange="Trip_Time()">
> <option value="choose" selected>Choose</option>
> <option value="High_Way1">High Way 1</option>
> <option value="High_Way2">High Way 2</option>
>
> </select> <font size="-1">Starting Location</font>
> <BR>
>
> Time at Location <input type=text name="reported_time" size=5
> value=""><br>
> ETA 1 <input type=text name="display_time" size=5 value="0:00"><br>
> ETA 2 <input type=text name="display_time2" size=5 value="0:00">
>
> </form>[/color]
You've posted so much conflicting code, hard to even guess at what
you're doing. In these instances, it's usually best to post some
(valid) HTML, with a simple description of what needs to happen.
Store the data in an object/array (same thing, really) and use the
selected option value as a 'key' to extract & process it.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>untitled</title>
<script type="text/javascript">
//<![CDATA[
var data = new Object;
data['High_Way1'] = '2:20|4:30';
data['High_Way2'] = '3:40|5:15';
data['default'] = '0:00|0:00';
function trip_time(selObj)
{
var sval = selObj.options[selObj.selectedIndex].value, //get selected
value
els = selObj.form.elements, //form elements
separator = '|', //separates data (above)
d = data[sval || 'default'].split(separator); //so, split it into an
array
els.display_time.value = d[0]; //output 1st element
els.display_time2.value = d[1]; //output 2nd element
}
//]]>
</script>
</head>
<body>
<form name="Traffic_Results">
<select name="CIP_Diff" onchange="return trip_time(this)">
<option value="" selected="selected">Choose</option>
<option value=""></option>
<option value="High_Way1">High Way 1</option>
<option value="High_Way2">High Way 2</option>
</select>
<font size="-1">Starting Location</font>
<br />
Time at Location <input type="text" name="reported_time" value=""
size="5" />
<br />
ETA 1 <input type="text" name="display_time" value="0:00" size="5"><br
/>
ETA 2 <input type="text" name="display_time2" value="0:00" size="5" />
</form>
</body>
</html>