Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / November 2004



Tip: Looking for answers? Try searching our database.

Pass variable from drop down option field to text fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan - 30 Nov 2004 01:56 GMT
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">
JF Larvoire - 30 Nov 2004 14:57 GMT
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
JF Larvoire - 30 Nov 2004 16:44 GMT
Oops,

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

JF
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.