468,119 Members | 1,689 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,119 developers. It's quick & easy.

Pass variable from drop down option field to text fields

Dan
Here is the working script if anyone is interested.

I was missing the else if.

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

function Trip_Time(Traffic_Results) {
if (document.Traffic_Results.CIP_Diff.value == "point1") {
document.Traffic_Results.display_time.value = "2:20";
document.Traffic_Results.display_time2.value = "4:30"; }

else if (document.Traffic_Results.CIP_Diff.value == "point2") {
document.Traffic_Results.display_time.value = "8:20";
document.Traffic_Results.display_time2.value = "11:30"; }

else if (document.Traffic_Results.CIP_Diff.value == "point3") {
document.Traffic_Results.display_time.value = "1:20";
document.Traffic_Results.display_time2.value = "6: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="" selected>Choose from this list</option>
<option value="point1">Point 1</option>
<option value="point2">Point 2</option>
<option value="point2">Point 3</option>
</select>&nbsp;&nbsp;&nbsp; <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">
Jul 23 '05 #1
2 1499
I'm doing the same thing in a page I'm working on right now, and it does NOT
work:
The text displayed in indeed updated.
But when the form is sent, it's the PREVIOUS contents of the text field that
are sent !?!
Same problem with IE6 and NS6.

Jean-François
Jul 23 '05 #2
Oops,

my mistake, the javascript work.
It's the php on the server side that was wrong.

JF
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by EviL KerneL | last post: by
1 post views Thread by Dan | last post: by
19 posts views Thread by nazgulero | last post: by
13 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.