Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change drop down values

Status
Not open for further replies.

antonyx6666

Programmer
Sep 9, 2010
38
GB
Hello, I have a drop down list on my form called DDPaddrType - let's call it Drop Down 1

Drop Down 1 - DDPaddrType
Code:
<select id="DDPaddrType" class="FormField" style="display:none;width:150px;" onChange="DDPaddrTypeChanged(this)" >
	<option>Please Select . . .</option>
	<option>Local Address</option>
</select>

Another <option> is added to this drop down list from a file called AddrShortcuts.js.inc. This extra <option> appears in the drop down list above as 'Heathrow Airport.' Below is the code in AddrShortcuts.js.inc which adds this <option>

AddrShortcuts.js.inc
Code:
// Place holder
var AS_Airport = 
    {
    group :
        "Heathrow Airport",

    premise:
        "Flight Number (eg VS401 Dubai)",

    shortcuts :
        [           

            ["HEATHROW TERMINAL 1", "Heathrow Airport - Terminal 1"],
	    ["HEATHROW TERMINAL 3", "Heathrow Airport - Terminal 3"],
	    ["HEATHROW TERMINAL 4", "Heathrow Airport - Terminal 4"],
	    ["HEATHROW TERMINAL 5", "Heathrow Airport - Terminal 5"]
	
        ]


	};


var AddressShortcuts = [AS_Airport];


I have another drop down list on the same form called DDvehAttr

Drop Down 2 - DDvehAttr
Code:
<select id="DDvehAttr" class="FormField" onchange="DDvehAttrChanged(this)" >
              <option value="-2">Please Select . . .</option>
<%
              for (i=0; i < vehAttr.length; i++)
              {%>
              <option value="<% = i %>"><% = vehAttr[i] %></option>
              <%}
%>
            </select>

This drop down is populated from another file called global.inc.

Code:
Session("ListAttributes")                = [

			["Standard Saloon", 	["01. Saloon [SAL]"]],
			["Executive Saloon", 	["07. Executive Saloon [EXEC-SAL]"]],
			["Estate Vehicle", 	["02. Estate [EST]"]],
			["People Carrier", 	["03. 5 Seater [5ST]"]],
			["8 Seater Vehicle", 	["06. 8 Seater [8ST]"]],		
						
					   ];


What I am trying to do is change the values of Drop Down 2 based on the value of Drop Down 1. Drop Down 1 has an onchange event called DDPaddrTypeChanged

DDPaddrTypeChanged
Code:
function DDPaddrTypeChanged(control)
{
    DDPaddrTypeIndex = control.selectedIndex;
    if (HandlePickup) HandlePickup.destruct();
    HandlePickup     = null;
    Validate(1, false);
    $("PAinput").hide();
    $("PAshow").innerHTML = "";
    defPickupIndex   = -1;
 
    SetPaddrType(true);
}


Is there a way to add a feature to the function above, in pseudo code i would want to achieve the following:

Code:
IF Drop Down 1 value = "Heathrow Airport" THEN
Drop Down 2 values are:
			["Standard Saloon",  [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
			["Executive Saloon",  [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
			["Estate Vehicle",  [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
			["People Carrier",  [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
			["8 Seater Vehicle",  [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]

ELSE
Drop Down 2 values are:
			["Standard Saloon", 	["01. Saloon [SAL]"]],
			["Executive Saloon", 	["07. Executive Saloon [EXEC-SAL]"]],
			["Estate Vehicle", 	["02. Estate [EST]"]],
			["People Carrier", 	["03. 5 Seater [5ST]"]],
			["8 Seater Vehicle", 	["06. 8 Seater [8ST]"]],

END IF



CONCLUSION
It has taken me 1 hour to prepare this post. I am very serious about getting this done ASAP. If nobody can see an obvious solution (code example for me to test) then can somebody PLEASE help me understand the logic of how this was built (off the shelf product) and how I can acheive this feature. If you need any additional code I CAN SUPPLY IT

Thanks
 
You'll need to check waht value is being selected in the inchage event and act accordingly. you could propabaly build another function you can call when the value from the first dropdown is the Heathrow airport value.

Code:
var AS_Airport =
    {
    group :
        "Heathrow Airport",

    premise:
        "Flight Number (eg VS401 Dubai)",

    shortcuts :
        [           

        ["HEATHROW TERMINAL 1", "Heathrow Airport - Terminal 1"],
        ["HEATHROW TERMINAL 3", "Heathrow Airport - Terminal 3"],
        ["HEATHROW TERMINAL 4", "Heathrow Airport - Terminal 4"],
        ["HEATHROW TERMINAL 5", "Heathrow Airport - Terminal 5"]
    
        ], 
    dd2options : [green]//Add your heathrow specific options to your heathrow object, or to another object[/green]
	    [
            
            ["Standard Saloon",  [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
            ["Executive Saloon",  [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
            ["Estate Vehicle",  [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
            ["People Carrier",  [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
            ["8 Seater Vehicle",  [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]
     
    
            ]
     
    };



</script>
<script>
function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
[green]//run a loop to populate drop down[/green]
for(var i=0; i<=AS_Airport.dd2options.length-1;i++){
var optn = document.createElement("OPTION");
optn.text = AS_Airport.dd2options[i];
optn.value = i;
dd2.options.add(optn);
}

}

function DDPaddrTypeChanged(control)
{
...
if(control.value="0"){ [green]//I'm assuming the value is 0, based on what you have[/green]
Repopulate_DD2();  [green]// Call your function to populate your dropdown.[/green]
}
...
}

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
hi there, thank you so much for helping me. really appreciate it.

i have added the DD2 options the code is as follows:

Code:
// Place holder
var AS_Airport =
    {
    group :
        "Heathrow Airport",

    premise:
        "Flight Number (eg VS401 Dubai)",

    shortcuts :
        [           

        ["HEATHROW TERMINAL 1", "Heathrow Airport - Terminal 1"],
        ["HEATHROW TERMINAL 3", "Heathrow Airport - Terminal 3"],
        ["HEATHROW TERMINAL 4", "Heathrow Airport - Terminal 4"],
        ["HEATHROW TERMINAL 5", "Heathrow Airport - Terminal 5"]
    
        ], 
    dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [
            
            ["Standard Saloon",  [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
            ["Executive Saloon",  [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
            ["Estate Vehicle",  [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
            ["People Carrier",  [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
            ["8 Seater Vehicle",  [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]
     
    
            ]
     
    };


Also in my main JS include file I have added the function you wrote (Repopulate_DD2) just above the original(DDPaddrTypeChanged) function (with the 2 new lines).

In it's current state the first drop down selection (DDPaddrType) still works but has zero effect on the second drop down (DDvehAttr)

Code:
function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
//run a loop to populate drop down
for(var i=0; i<=AS_Airport.dd2options.length-1;i++){
var optn = document.createElement("OPTION");
optn.text = AS_Airport.dd2options[i];
optn.value = i;
dd2.options.add(optn);
}

}





function DDPaddrTypeChanged(control)
{
    DDPaddrTypeIndex = control.selectedIndex;
    if (HandlePickup) HandlePickup.destruct();
    HandlePickup     = null;
    Validate(1, false);
    $("PAinput").hide();
    $("PAshow").innerHTML = "";
    defPickupIndex   = -1;
 
    SetPaddrType(true);

    if(control.value="0"){ //I'm assuming the value is 0, based on what you have
    Repopulate_DD2();  // Call your function to populate your dropdown.

}
 
This
Code:
if(control.value="0"){ //I'm assuming the value is 0, based on what you have
    Repopulate_DD2();  // Call your function to populate your dropdown.

should be

Code:
if(control.value=[red]=[/red]"0"){ //I'm assuming the value is 0, based on what you have
    Repopulate_DD2();  // Call your function to populate your dropdown.

Now, do you get any a errors? Most browsers have ways of showing errors from Javascript. IE uses the little gold shied icon on the left bottom corner, firefox uses its Error Console.

I need any errors to be able to debug.

I tested the code and it worked for me in a sample test harness. which of course is missing a lot of stuff you may have in there that may be causing issues.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
hi there, the form is not giving me errors. it seems to be happy (code wise) but the actual drop downs are not interacting with each other. basically the plan is that when 'Heathrow Airport' is selected - one set of values is loaded... when another option is selected another set of values is loaded.

Here is the actual shortcut code. this is how ideally i want it to work

Code:
// Place holder
var AS_Airport =
    {
    group :
        "Heathrow Airport",

    premise:
        "Flight Number (eg VS401 Dubai)",

    shortcuts :
        [           

        ["HEATHROW TERMINAL 1", "Heathrow Airport - Terminal 1"],
        ["HEATHROW TERMINAL 3", "Heathrow Airport - Terminal 3"],
        ["HEATHROW TERMINAL 4", "Heathrow Airport - Terminal 4"],
        ["HEATHROW TERMINAL 5", "Heathrow Airport - Terminal 5"]
    
        ], 
    dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [
            
            ["Standard Saloon",  [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
            ["Executive Saloon",  [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
            ["Estate Vehicle",  [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
            ["People Carrier",  [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
            ["8 Seater Vehicle",  [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]
     
    
            ]
     
    };




var AH_Hotel = 
    {
    group :
        "Heathrow Hotel",

    premise:
        "Room Number (if known)",

    shortcuts :
        [           

	    ["ARORA LHR", "Arora Park Hotel Heathrow, Old Bath Road, Poyle, SL3 0NZ"],
	    ["CROWNE PLAZA LHR", "Crowne Plaza Heathrow Hotel, Stockley Road, West Drayton, UB7 9BW"],
	    ["MARRIOTT WINDSOR LHR", "Heathrow & Windsor Marriott, Ditton Road Langley, SL3 8PT"],
	    ["COMFORT INN LHR", "Heathrow Comfort Inn Hotel, Shepiston Lane, Hayes, UB3 1LP"],
	    ["COPTHORNE SLOUGH LHR", "Heathrow Copthorne Slough Windsor, 400 Cippenham Lane, Slough, SL1 2YE"],
	    ["SHERATON LHR", "Heathrow Sheraton Hotel, Colnbrook By Pass, West Drayton, UB7 0HJ"],
	    ["THISTLE LHR", "Heathrow Thistle Hotel, Bath Road, Longford, West Drayton, UB7 0EQ"],
	    ["HILTON LHR", "Hilton Hotel Heathrow, Terminal 4, Scylla Road, TW6 3AF"],
	    ["HOLIDAY INN LHR", "Holiday Inn London Heathrow, Bath Road, Corner Sipson Way, West Drayton, UB7 0DP"],
	    ["HOLIDAY INN AERIAL", "Holiday Inn Aerial Hotel, 118 Bath Road, Hayes, UB3 5AJ"],
	    ["HOLIDAY INN M4", "Holiday Inn M4 Heathrow Hotel, M4 Jnct 4, Sipson Road, UB7 9DJ"],
	    ["IBIS LHR", "Ibis London Heathrow Hotel, 112 Bath Road, Hayes, UB3 5AL"],
	    ["JURYS INN LHR", "Jurys Inn Hotel, Eastern Perimeter Road, Hatton Cross, TW6 2SR"],
	    ["MARRIOTT LHR", "Marriott Heathrow Hotel, Bath Road, Harlington, Hayes, UB3 5AN"],
	    ["NOVOTEL LHR", "Novotel Heathrow Hotel, Cherry Lane, West Drayton, UB7 9HD"],
	    ["PARK INN LHR", "Park Inn Heathrow Hotel, Bath Road, West Drayton, UB7 0DU"],
	    ["RADISSON LHR", "Radisson Edwardian Hotel, 140 Bath Road, Hayes, UB3 5AW"],
	    ["RENAISSANCE LHR", "Renaissance London Heathrow Hotel, Bath Road, Hounslow, TW6 2AQ"],
	    ["SHERATON SKYLINE LHR", "Sheraton Skyline Hotel, Bath Road, Hayes, UB3 5BP"],
	    ["SOFITEL LHR", "Sofitel Heathrow Hotel, Terminal 5, Heathrow Airport, TW6 2GD"], 
    
    dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [
            
            ["Standard Saloon",     ["01. Saloon [SAL]"]],
            ["Executive Saloon",     ["07. Executive Saloon [EXEC-SAL]"]],
            ["Estate Vehicle",     ["02. Estate [EST]"]],
            ["People Carrier",     ["03. 5 Seater [5ST]"]],
            ["8 Seater Vehicle",     ["06. 8 Seater [8ST]"]],

     
    
            ]
     
    };


var CH_CarHire = 
    {
    group :
        "Heathrow Car Hire",

    premise:
        " ",

    shortcuts :
        [           

	    ["AVIS LHR", "Avis Car Hire, Northrop Road, Heathrow Airport, TW6 2QA"],
	    ["BUDGET LHR", "Budget Rent a Car, Northrop Road, Heathrow Airport, TW6 2QA"],
	    ["ENTERPRISE LHR", "Enterprise Rent-A-Car, Northern Perimeter Road, Heathrow Airport, TW6 2RG"],
	    ["EUROPCAR LHR", "Europcar, Northern Perimeter Road West, Heathrow Airport, TW6 2QE"],
    	    ["HERTZ LHR", "Hertz Car Hire, Northern Perimeter Road, Heathrow Airport, TW6 2QD"],
	    ["NATIONAL LHR", "National Car Rental, Northern Perimeter Road West, Heathrow Airport, TW6 2QE"],

	        dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [
            
            ["Standard Saloon",     ["01. Saloon [SAL]"]],
            ["Executive Saloon",     ["07. Executive Saloon [EXEC-SAL]"]],
            ["Estate Vehicle",     ["02. Estate [EST]"]],
            ["People Carrier",     ["03. 5 Seater [5ST]"]],
            ["8 Seater Vehicle",     ["06. 8 Seater [8ST]"]],

     
    
            ]
	
        ]


	};


var AddressShortcuts = [AS_Airport, AH_Hotel, CH_CarHire];


you can actually see the website here:
http://londonheathrowcars-accounts/webbookercc/OneForm.asp

When the form loads, by default the second drop down menu loads the following:

Code:
Session("ListAttributes")                = [

			["Standard Saloon", 	["01. Saloon [SAL]"]],
			["Standard Saloon including Meet & Greet",  [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
			["Executive Saloon", 	["07. Executive Saloon [EXEC-SAL]"]],
			["Executive Saloon including Meet & Greet",  [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
			["Estate Vehicle", 	["02. Estate [EST]"]],
			["Estate Vehicle including Meet & Greet",  [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
			["People Carrier", 	["03. 5 Seater [5ST]"]],
			["People Carrier including Meet & Greet",  [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
			["8 Seater Vehicle", 	["06. 8 Seater [8ST]"]],
			["8 Seater Vehicle including Meet & Greet",  [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]			];

this is loaded from a file called global.inc

it is when the user chooses a value in the drop down menu titled Pickup Address that i want the values to change but it doesnt seem to be changing anything right now or producing any error.


thanks
 
The code I'm seeing does not show the added If statement inside the DDPaddrTypeChanged() function.

It should be working now once you add the If statement.


Code:
function DDPaddrTypeChanged(control)
{
    DDPaddrTypeIndex = control.selectedIndex;
    if (HandlePickup) HandlePickup.destruct();
    HandlePickup     = null;
    Validate(1, false);
    $("PAinput").hide();
    $("PAshow").innerHTML = "";
    defPickupIndex   = -1;
 
    SetPaddrType(true);

if(control.value="0"){ //I'm assuming the value is 0, based on what you have
alert('Repopulating');
Repopulate_DD2();  // Call your function to populate your dropdown.
}
}

Also are you sure there are no errors.

Look for the yellow shield icon on the bottom left corner of the browser, and double click it. If there are any errors it will pop up a window with them listed.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
im so sorry!!!! i was editing the BACKUP COPY of the website!!!

oh dear. this is what 12 hours without a break does to you. let me edit the ACTUAL website and test it.

 
ok, i have the following code in my AddShortcuts file:

Code:
var AS_Airport =
    {
    group :
        "Heathrow Airport",

    premise:
        "Flight Number (eg VS401 Dubai)",

    shortcuts :
        [           

        ["HEATHROW TERMINAL 1", "Heathrow Airport - Terminal 1"],
        ["HEATHROW TERMINAL 3", "Heathrow Airport - Terminal 3"],
        ["HEATHROW TERMINAL 4", "Heathrow Airport - Terminal 4"],
        ["HEATHROW TERMINAL 5", "Heathrow Airport - Terminal 5"]
    
        ], 
    dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [
            
            ["Standard Saloon",  [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
            ["Executive Saloon",  [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
            ["Estate Vehicle",  [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
            ["People Carrier",  [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
            ["8 Seater Vehicle",  [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]
     
    
            ]
     
    };



var AH_Hotel = 
    {
    group :
        "Heathrow Hotel",

    premise:
        "Room Number (if known)",

    shortcuts :
        [           

        ["ARORA LHR", "Arora Park Hotel Heathrow, Old Bath Road, Poyle, SL3 0NZ"],
        ["CROWNE PLAZA LHR", "Crowne Plaza Heathrow Hotel, Stockley Road, West Drayton, UB7 9BW"],
        ["MARRIOTT WINDSOR LHR", "Heathrow & Windsor Marriott, Ditton Road Langley, SL3 8PT"],
        ["COMFORT INN LHR", "Heathrow Comfort Inn Hotel, Shepiston Lane, Hayes, UB3 1LP"],
        ["COPTHORNE SLOUGH LHR", "Heathrow Copthorne Slough Windsor, 400 Cippenham Lane, Slough, SL1 2YE"],
        ["SHERATON LHR", "Heathrow Sheraton Hotel, Colnbrook By Pass, West Drayton, UB7 0HJ"],
        ["THISTLE LHR", "Heathrow Thistle Hotel, Bath Road, Longford, West Drayton, UB7 0EQ"],
        ["HILTON LHR", "Hilton Hotel Heathrow, Terminal 4, Scylla Road, TW6 3AF"],
        ["HOLIDAY INN LHR", "Holiday Inn London Heathrow, Bath Road, Corner Sipson Way, West Drayton, UB7 0DP"],
        ["HOLIDAY INN AERIAL", "Holiday Inn Aerial Hotel, 118 Bath Road, Hayes, UB3 5AJ"],
        ["HOLIDAY INN M4", "Holiday Inn M4 Heathrow Hotel, M4 Jnct 4, Sipson Road, UB7 9DJ"],
        ["IBIS LHR", "Ibis London Heathrow Hotel, 112 Bath Road, Hayes, UB3 5AL"],
        ["JURYS INN LHR", "Jurys Inn Hotel, Eastern Perimeter Road, Hatton Cross, TW6 2SR"],
        ["MARRIOTT LHR", "Marriott Heathrow Hotel, Bath Road, Harlington, Hayes, UB3 5AN"],
        ["NOVOTEL LHR", "Novotel Heathrow Hotel, Cherry Lane, West Drayton, UB7 9HD"],
        ["PARK INN LHR", "Park Inn Heathrow Hotel, Bath Road, West Drayton, UB7 0DU"],
        ["RADISSON LHR", "Radisson Edwardian Hotel, 140 Bath Road, Hayes, UB3 5AW"],
        ["RENAISSANCE LHR", "Renaissance London Heathrow Hotel, Bath Road, Hounslow, TW6 2AQ"],
        ["SHERATON SKYLINE LHR", "Sheraton Skyline Hotel, Bath Road, Hayes, UB3 5BP"],
        ["SOFITEL LHR", "Sofitel Heathrow Hotel, Terminal 5, Heathrow Airport, TW6 2GD"] 

    
        ], 
    dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [
            
            ["Standard Saloon",     ["01. Saloon [SAL]"]],
            ["Executive Saloon",     ["07. Executive Saloon [EXEC-SAL]"]],
            ["Estate Vehicle",     ["02. Estate [EST]"]],
            ["People Carrier",     ["03. 5 Seater [5ST]"]],
            ["8 Seater Vehicle",     ["06. 8 Seater [8ST]"]],
     
    
            ]
     
    };





var AddressShortcuts = [AS_Airport,AH_Hotel];

function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
//run a loop to populate drop down
for(var i=0; i<=AS_Airport.dd2options.length-1;i++){
var optn = document.createElement("OPTION");
optn.text = AS_Airport.dd2options[i];
optn.value = i;
dd2.options.add(optn);
}

}

function DDPaddrTypeChanged(control)
{
    DDPaddrTypeIndex = control.selectedIndex;
    if (HandlePickup) HandlePickup.destruct();
    HandlePickup     = null;
    Validate(1, false);
    $("PAinput").hide();
    $("PAshow").innerHTML = "";
    defPickupIndex   = -1;
 
    SetPaddrType(true);

if(control.value=="0"){ //I'm assuming the value is 0, based on what you have
alert('Repopulating');
Repopulate_DD2();  // Call your function to populate your dropdown.
}
}


the form is working as it should and there are no errors on the browser, BUT the second drop down is not updating based on the Heathrow Airport selection in the first drop down.
 
ok what i have done is put ALL the code (shortcut code and onchange code) in the same file. i have pasted the WHOLE code because I think the default value maybe set to 1, or there could be something else causing this not to work. you can see the code below and i have highlighted in bold the parts we are focused on:

Code:
<!-- $Header: /Projects/Taxi/WebBooker/WJBasp.NV/includes/OneForm.js.inc 32    18/12/08 12:03 David.g $ -->
<SCRIPT type="text/javascript">
//<![CDATA[

var serverTimeLead      = 0;
var PUtimeChanged       = false;
var PUtimeValid         = false;
var validityMask        = <% = ((vehAttr.length > 0) ? 0 : 8) + ((mandRefMask ^ 0x00F) << 8) %>;
var vehAttribIndex      = <% = hasQuote ? Session("VAindex") : -2 %>;
var DDPaddrTypeIndex    = <% = hasQuote ? Session("PTindex") : 0 %> ;
var DDDaddrTypeIndex    = <% = hasQuote ? Session("DTindex") : 0 %> ;
var PickupDateTime      = "0";
var shadowOptions       = { distance: 5, angle: 135, opacity: 0.5, nestedShadows: 3 };
var HandlePickup        = null;
var HandleDropoff       = null;
var nationwideSearch    = <% = Session("NationwideSearch") ? 'true' : 'false' %> ;
var defPickupIndex      = -1;
var defDropoffIndex     = -1;
var HelpT               = [];

var noJob = 0;

/*
LOG = function() { };

if (typeof console == 'object') LOG = console.log;
*/

function OnLoad()
{
    var mbs = $$(".Tick");

    for (i=0; i < mbs.length; i++)
    {
       mbs[i].style.visibility = "hidden";
    }

    <% if (Session("AddressShortcuts") || Session("NationwideSearch")) { %>
    
    if (nationwideSearch)
    {
        var option = "<option>Any Address</option>";
        $("DDPaddrType").insert(option);
        $("DDDaddrType").insert(option);
    }
    
    <% if (Session("AddressShortcuts")) { %>
    if (typeof <% = Session("AddressShortcuts") %> == 'object')
    {
        for (var i=0; i < <% = Session("AddressShortcuts") %>.length; i++)
        {
            var option = "<option>" + <% = Session("AddressShortcuts") %>[i].group + "</option>";
            $("DDPaddrType").insert(option);
            $("DDDaddrType").insert(option);
        }
    }
    <% } %>

    $("DDPaddrType").selectedIndex  = DDPaddrTypeIndex;
    $("DDPaddrType").show();
    $("DDDaddrType").selectedIndex  = DDDaddrTypeIndex;
    $("DDDaddrType").show();
    <% } else  { %>
    DDPaddrTypeIndex = 1;
    DDDaddrTypeIndex = 1;
    SetPaddrType(<% = hasQuote ? "false" : "true" %>);
    SetDaddrType(<% = hasQuote ? "false" : "true" %>);
    <% } %>

    <% if (vehAttr.length > 0) { %>
    document.getElementById("DDvehAttr").selectedIndex = vehAttribIndex + 2;
    <% } %>

    var now         = new Date();
    serverTimeLead = (now.getTimezoneOffset()) - (<% = d.getTimezoneOffset() %>);
    serverTimeLead *= 60000.0;

    if (serverTimeLead) $("PickupTimeLegend").innerHTML = "UK Local:&nbsp;&nbsp;";

    <% if (hasQuote) { %>
    now.setTime(<% = Session("Job").NominalPickupTime %> + (serverTimeLead));
    <% } else { %>
    now.setTime(now.getTime() + <% = (leadTimeTicks > 0) ? leadTimeTicks : 0 %> + (serverTimeLead));
    <% } %>

    formDateTime(now, document.mainForm.PickupTime, document.mainForm.PickupDate);

    if (!ie)
    {
        initCal(); 
    }

    document.notifyCalendarChange();

   <% if ((Session("PAlist"))
      &&  (Session("PAindex") >= 0)) { %>
    SetPaddrType(false);
    defPickupIndex                              = <% = Session("PAindex") %>;
    if (HandlePickup ) HandlePickup.serverIndex = defPickupIndex;
    document.getElementById('PAshow').innerHTML = "<% = Session("PPremise") + Session("PAlist").Address(Session("PAindex")) + ' ' + Session("PAlist").Postcode(Session("PAindex")) %>";
    Validate(1, true);
    <% } %>

   <% if ((Session("DAlist"))
      &&  (Session("DAindex") >= 0)) { %>
    SetDaddrType(false);
    defDropoffIndex                              = <% = Session("DAindex") %>;
    if (HandleDropoff) HandleDropoff.serverIndex = defDropoffIndex;
    document.getElementById('DAshow').innerHTML = "<% = Session("DAlist").Address(Session("DAindex")) + ' ' + Session("DAlist").Postcode(Session("DAindex")) %>";
    Validate(2, true);
    <% } %>

    <% if (hasQuote) { %>
    Validate(3, true);
    <% } %>

    <% if (!Session("User").IsNewUser) { %>
    new CUserHandler("PassengerName",   function(t) { Validate(5,t) }); 
    new CUserHandler("PaxTelephoneNum", function(t) { Validate(6,t) }); 
    <% if (Application("WJB").UseEmail && Session("EmailIsMandatory")) { %>
    new CUserHandler("CustomerEmail",   function(t) { Validate(7,t) }); 
    <% } else { %>
    Validate(7,true);
    <% } %>
    for (var i=0; i < 4; i++)
    {
        var t = $("Ref" + i);
        if (t && (t.tagName.toLowerCase() == 'input'))
        {
            new CRefTextHandler(i);
        }
    }
    <% } %>

    <% if (Session("User").IsNewUser && (!hasQuote)) { %>
    new Ajax.Request('MAjax.asp',{ parameters: {A: "P", S: "mi"} });
    <% } %>

    HelpT.R0  = "Enter the required Pickup Date and Time.";
    <% if (leadTimeTicks > 0) { %>
    HelpT.R0 += " You must book at least <% = Session('User').LeadTimeFormatted %> in advance.";
    <% } %>
    HelpT.R1  = "Enter the Pickup Address. First select the type of address you want, then search for the exact place.";
    HelpT.R2  = "Enter the Dropoff Address. First select the type of address you want, then search for the exact place.";
    HelpT.R3  = "For your convenience, we offer a choice of vehicles. Choose the most appropriate type of Vehicle for your needs.";
    HelpT.R4  = 
    <% if (!!Session("SuppressChargesBeforeBooked")) { %>
    "Indicates whether we have enough information to book a trip.";
    <% } else { %>
    "Indicates the cost of the trip.";
    <% } %>
    HelpT.R5  = "Enter the Passenger Name. This is a mandatory field.";
    HelpT.R6  = "Enter a contact Telephone Number. This is a mandatory field.";
    HelpT.R7  = "Enter a contact Email address. This is a<% = Session("EmailIsMandatory") ? " mandatory" : "n optional" %> field.";
    <% for (var r=0; r < 4; r++) 
    {
       var job = Session("Job"); %>
    HelpT.R<% = 8+r %> = "Enter an appropriate value for the '<% = Literal(job.GetReferenceName(r)) %>' reference.";
    <% } %>
}

function OnLoadMove(elementID)
{
    var c        = document.getElementById(elementID);
    var x        = c.offsetLeft;
    x           += 60;
    c.style.left = x + "px";
}

var delayHelp   = null;
var unDelayHelp = null;

function Help(tr)
{
    if (delayHelp)
    {
        clearTimeout(delayHelp);
    }

    if (unDelayHelp)
    {
        clearTimeout(unDelayHelp);
        unDelayHelp = null;
    }

    $("HD").innerHTML = HelpT[$(tr).id];
    delayHelp = setTimeout(HelpDelayed, 800);
}

function HelpDelayed()
{
    delayHelp = null;
    $("HB").show();
}

function UnHelp(tr)
{
    if (delayHelp)
    {
        clearTimeout(delayHelp);
        delayHelp = null;
    }

    if (unDelayHelp)
    {
        clearTimeout(unDelayHelp);
    }

    unDelayHelp = setTimeout(UnHelpDelayed, 800);
}

function UnHelpDelayed()
{
    unDelayHelp = null;
    $("HB").hide();
}

var dhFirst = true;

function DetailedHelp(tr)
{
    if (dhFirst)
    {
       $("helpLayer").style.width = "350px";
       $("helpLayer").style.left  = "20px";
       $("helpLayer").style.top   = "20px";
       dhFirst = false;
    }

    var elements = $(tr).ancestors();
    for (var i=0; i < elements.length; i++)
    {
        if ((elements[i].tagName == "TR")
        &&  (String(elements[i].id).substr(0,1) == "R"))
        {
            var AS = "";

            <% if (Session("AddressShortcuts")) { %>
            if (typeof <% = Session("AddressShortcuts") %> == 'object')
            {
                for (var j=0; j < <% = Session("AddressShortcuts") %>.length; j++)
                {
                    AS = AS + ((j > 0) ? ", " : "") + <% = Session("AddressShortcuts") %>[j].group;
                }
            }
            <% } %>

            new Ajax.Request(
              'MAhelp.asp',
              {
                 onSuccess: ProcessHelp,
                 parameters: { H: String(elements[i].id), L: serverTimeLead, A: AS }
              });

            break;
        }
    }
}

function ProcessHelp(transport)
{
    $("fullHelpText").innerHTML = transport.responseText;
    showHelp();
}




[b]
var AS_Airport =
    {
    group :
        "Heathrow Airport",

    premise:
        "Flight Number (eg VS401 Dubai)",

    shortcuts :
        [           

        ["HEATHROW TERMINAL 1", "Heathrow Airport - Terminal 1"],
        ["HEATHROW TERMINAL 3", "Heathrow Airport - Terminal 3"],
        ["HEATHROW TERMINAL 4", "Heathrow Airport - Terminal 4"],
        ["HEATHROW TERMINAL 5", "Heathrow Airport - Terminal 5"]
    
        ], 
    dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [
            
            ["Standard Saloon",  [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
            ["Executive Saloon",  [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
            ["Estate Vehicle",  [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
            ["People Carrier",  [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
            ["8 Seater Vehicle",  [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]
     
    
            ]
     
    };



var AH_Hotel = 
    {
    group :
        "Heathrow Hotel",

    premise:
        "Room Number (if known)",

    shortcuts :
        [           

        ["ARORA LHR", "Arora Park Hotel Heathrow, Old Bath Road, Poyle, SL3 0NZ"],
        ["CROWNE PLAZA LHR", "Crowne Plaza Heathrow Hotel, Stockley Road, West Drayton, UB7 9BW"],
        ["MARRIOTT WINDSOR LHR", "Heathrow & Windsor Marriott, Ditton Road Langley, SL3 8PT"],
        ["COMFORT INN LHR", "Heathrow Comfort Inn Hotel, Shepiston Lane, Hayes, UB3 1LP"],
        ["COPTHORNE SLOUGH LHR", "Heathrow Copthorne Slough Windsor, 400 Cippenham Lane, Slough, SL1 2YE"],
        ["SHERATON LHR", "Heathrow Sheraton Hotel, Colnbrook By Pass, West Drayton, UB7 0HJ"],
        ["THISTLE LHR", "Heathrow Thistle Hotel, Bath Road, Longford, West Drayton, UB7 0EQ"],
        ["HILTON LHR", "Hilton Hotel Heathrow, Terminal 4, Scylla Road, TW6 3AF"],
        ["HOLIDAY INN LHR", "Holiday Inn London Heathrow, Bath Road, Corner Sipson Way, West Drayton, UB7 0DP"],
        ["HOLIDAY INN AERIAL", "Holiday Inn Aerial Hotel, 118 Bath Road, Hayes, UB3 5AJ"],
        ["HOLIDAY INN M4", "Holiday Inn M4 Heathrow Hotel, M4 Jnct 4, Sipson Road, UB7 9DJ"],
        ["IBIS LHR", "Ibis London Heathrow Hotel, 112 Bath Road, Hayes, UB3 5AL"],
        ["JURYS INN LHR", "Jurys Inn Hotel, Eastern Perimeter Road, Hatton Cross, TW6 2SR"],
        ["MARRIOTT LHR", "Marriott Heathrow Hotel, Bath Road, Harlington, Hayes, UB3 5AN"],
        ["NOVOTEL LHR", "Novotel Heathrow Hotel, Cherry Lane, West Drayton, UB7 9HD"],
        ["PARK INN LHR", "Park Inn Heathrow Hotel, Bath Road, West Drayton, UB7 0DU"],
        ["RADISSON LHR", "Radisson Edwardian Hotel, 140 Bath Road, Hayes, UB3 5AW"],
        ["RENAISSANCE LHR", "Renaissance London Heathrow Hotel, Bath Road, Hounslow, TW6 2AQ"],
        ["SHERATON SKYLINE LHR", "Sheraton Skyline Hotel, Bath Road, Hayes, UB3 5BP"],
        ["SOFITEL LHR", "Sofitel Heathrow Hotel, Terminal 5, Heathrow Airport, TW6 2GD"] 

    
        ], 
    dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [
            
            ["Standard Saloon",     ["01. Saloon [SAL]"]],
            ["Executive Saloon",     ["07. Executive Saloon [EXEC-SAL]"]],
            ["Estate Vehicle",     ["02. Estate [EST]"]],
            ["People Carrier",     ["03. 5 Seater [5ST]"]],
            ["8 Seater Vehicle",     ["06. 8 Seater [8ST]"]]
     
    
            ]
     
    };




var AddressShortcuts = [AS_Airport,AH_Hotel];



function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
//run a loop to populate drop down
for(var i=0; i<=AS_Airport.dd2options.length-1;i++){
var optn = document.createElement("OPTION");
optn.text = AS_Airport.dd2options[i];
optn.value = i;
dd2.options.add(optn);
}

}

function DDPaddrTypeChanged(control)
{
    DDPaddrTypeIndex = control.selectedIndex;
    if (HandlePickup) HandlePickup.destruct();
    HandlePickup     = null;
    Validate(1, false);
    $("PAinput").hide();
    $("PAshow").innerHTML = "";
    defPickupIndex   = -1;
 
    SetPaddrType(true);

if(control.value=="0"){ //I'm assuming the value is 0, based on what you have
alert('Repopulating');
Repopulate_DD2();  // Call your function to populate your dropdown.
}
}

function SetPaddrType(p)
{
    var v = function(t) { Validate(1, t) };

    if (DDPaddrTypeIndex == 1)
    {
        HandlePickup = new CAddressHandlerSearch("PAinput", "PAshow", "P", v, false);
    }
    else if ((nationwideSearch) && (DDPaddrTypeIndex == 2))
    {
        HandlePickup = new CAddressHandlerSearch("PAinput", "PAshow", "P", v, true);
    }
    else if (DDPaddrTypeIndex > 1)
    {
        HandlePickup = new CAddressHandlerShortcuts("PAinput", "PAshow", "P", v, <% = Session("AddressShortcuts") %>[DDPaddrTypeIndex - (nationwideSearch ? 3 : 2)]);
    }

    if (p && HandlePickup) HandlePickup.Prompt();
}


[/b]





function DDDaddrTypeChanged(control)
{
    DDDaddrTypeIndex = control.selectedIndex;
    if (HandleDropoff) HandleDropoff.destruct();
    HandleDropoff    = null;
    Validate(2, false);
    $("DAinput").hide();
    $("DAshow").innerHTML = "";
    defDropoffIndex = -1;

    SetDaddrType(true);
}

function SetDaddrType(p)
{
    var v = function(t) { Validate(2, t) };

    if (DDDaddrTypeIndex == 1)
    {
        HandleDropoff = new CAddressHandlerSearch("DAinput", "DAshow", "D", v, false);
    }
    else if ((nationwideSearch) && (DDDaddrTypeIndex == 2))
    {
        HandleDropoff = new CAddressHandlerSearch("DAinput", "DAshow", "D", v, true);
    }
    else if (DDDaddrTypeIndex > 1)
    {
        HandleDropoff = new CAddressHandlerShortcuts("DAinput", "DAshow", "D", v, <% = Session("AddressShortcuts") %>[DDDaddrTypeIndex - (nationwideSearch ? 3 : 2)]);
    }

    if (p && HandleDropoff) HandleDropoff.Prompt();
}

function DDvehAttrChanged(control)
{
    vehAttribIndex = Number(control.options[control.selectedIndex].value);
    Validate(3, vehAttribIndex >= -1);
}

function CheckPUtime(f)
{
    if (!PUtimeChanged)
    {
        return;
    }

    var puTime     = new Date();
    var now        = new Date();
    var e          = makeDateTime(f.PickupTime, f.PickupDate, puTime);
    PUtimeValid    = false;
    PUtimeChanged  = false;
    PickupDateTime = "0";

    now.setTime(now.getTime() + serverTimeLead);

    if (e == 1)
    {
        alert("Pickup Time is invalid\n\nCorrect value should be like 12:30 or 23:59");
        f.PickupTime.focus();
    }
    else if (e == 2)
    {
        alert("Pickup Date is invalid");
    }
    else if ((now.getTime() - puTime.getTime()) > (5 * 60 * 1000))
    {
        alert("Pickup time can't be in the past");
    }
    else if ((now.getTime() - puTime.getTime()) > ((5 * 60 * 1000) - <% = leadTimeTicks %>))
    {
        alert("You must book at least <% = Session('User').LeadTimeFormatted %> in advance");
    }
    else
    {
        PUtimeValid    = true;
        PickupDateTime = String(puTime.getTime() - serverTimeLead);
    }

    Validate(0, PUtimeValid);
}

function Validate(flag, isValid)
{
    if (flag < 4)
    {
        document.getElementById("Tick4").style.visibility   = "hidden";
        document.getElementById("BookNow").style.visibility = "hidden";
        document.getElementById("Quote").innerHTML          = "";
    }

    var m = (1 << flag);

    if (isValid)
    {
        validityMask |= m;
    } 
    else
    {
        validityMask &= (~m);
    } 

    var e = document.getElementById("Tick" + flag);
    if (e) e.style.visibility = isValid ? "visible" : "hidden";

    if ((isValid)
    &&  ((validityMask & 15) == 15)
    &&  (flag < 4))
    {
        // Do ajax quotation here
        var post = {
           T  : PickupDateTime,
           PT : DDPaddrTypeIndex,
           DT : DDDaddrTypeIndex,
           P  : HandlePickup  ? HandlePickup.serverIndex : defPickupIndex,
           D  : HandleDropoff ? HandleDropoff.serverIndex : defDropoffIndex,
           V  : vehAttribIndex
        };

        new Ajax.Request(
            'MAjax.asp',
            {
                onSuccess: ProcessQuotation,
                parameters: post
            });
    }




    if ($("NextButton"))
    {
	
        if ((isValid)
        &&  ((validityMask & 4095) == 4095))
        {
	    $("NextButton").show();
        }
        else
        {
            $("NextButton").hide();
        }
	
    }

}



var ProcessQuotation = function(transport)
{
    noJob = 0;
    //set noJob flag back to zero
    var response = transport.responseText;
   
    if (response.indexOf("Invalid Job Charge") > 0) 
    {
    response = "To receive a custom quote for this journey please call our office on: +44 (0)20 8814 2727" ;
    Validate(4, false);
    noJob = 1;
    }
    else
    {
    Validate(4, true);
    <% if (!!Session("SuppressChargesBeforeBooked")) { %>
    if (response.indexOf("Error") < 0) response = "Ready to Book";
    <% } %>
    }
 

    document.getElementById("Quote").innerHTML = response;
    <% if (Session("User").IsNewUser) { %>
	//If isNewUSer and noJob = 1
	if(noJob == 1 )
	{
	 document.getElementById("BookNow").style.visibility = "hidden";

	}
	else
	{
    document.getElementById("BookNow").style.visibility = "visible";
    
    }
    <% } %>
}

document.notifyCalendarChange = function() 
{
    PUtimeChanged = true;
    CheckPUtime(document.getElementById("mainForm"));
}

var CUserHandler = Class.create(
    {
    initialize:
        function(inputElement, validate)
        {
            this.inputElement = $(inputElement);
            this.Validate     = validate;
            this.valid        = false;

            this.inputElement.observe('keyup', this.OnChange.bindAsEventListener(this));
            this.OnChange();
        }
        ,
    OnChange:
        function(e)
        {
            var wasValid = this.valid;
            this.valid   = this.inputElement.value != "";

            if (wasValid != this.valid)
            {
                this.Validate(this.valid);
            }
        }
    }
);

function Check(i, t)
{
    if (i.value == "")
    {
        alert(t + " can't be empty");
        i.focus();
        return false;
    }

    return true;
}

function PassPax(wizard)
{
    var post = {
       P  : $("PassengerName").value,
       T  : $("PaxTelephoneNum").value,
       <% if (Application("WJB").UseEmail) { %>
       E  : $("CustomerEmail").value,
	   <% } else { %>
       E  : "",
	   <% } %>
       W  : wizard ? "Y" : "N",
       PI : HandlePickup  ? HandlePickup.serverIndex : defPickupIndex,
       DI : HandleDropoff ? HandleDropoff.serverIndex : defDropoffIndex
    };

    new Ajax.Request(
        'MAjax.asp',
        {
            onSuccess: function() { location = wizard ? "<% = nextWizardStep %>" : "<% = nextStep %>"; },
            parameters: post
        });
}

function CheckForm()
{
    var ok = Check($("PassengerName"), "Passenger Name");
    ok     = ok && Check($("PaxTelephoneNum"), "Telephone Number");
    <% if (Application("WJB").UseEmail && Session("EmailIsMandatory")) { %>
    ok     = ok && Check($("CustomerEmail"), "E-Mail field");
    <% } %>

    if (ok) PassPax(false);
}

function GoWizard()
{
    PassPax(true);
}

function RefChoiceChanged(control, refIndex)
{
   var sel = control.selectedIndex;
   var ref = control.options[sel].innerHTML;
   
   Validate(refIndex + 8, control.options[sel].value);

   new Ajax.Request(
       'MAjax.asp',
       {
       parameters:
           { R: refIndex, V: ref }
       });
}

function Login()
{
    location = ((validityMask & 31) == 31) ? "OneFormLogin.asp" : "default.asp?L=1";
}

var CRefTextHandler = Class.create(
    {
    initialize:
        function(refIndex)
        {
            this.refIndex       = refIndex;
            this.inputElement   = $("Ref" + refIndex);
            this.inputValue     = "";
            this.requestPending = false;
            this.timer          = null;
            
            this.fOnBlur    = this.OnBlur.bindAsEventListener(this);
            this.fOnKeyUp   = this.OnKeyUp.bindAsEventListener(this); 
            this.fAddressChange = this.AddressChange.bind(this);

            this.inputElement.observe('blur',  this.fOnBlur  );
            this.inputElement.observe('keyup', this.fOnKeyUp );
        }
        ,
    OnBlur:
        function(e)
        {
            if (this.inputElement.value != this.inputValue)
            {
                if (this.timer)
                {
                    clearTimeout(this.timer);
                    this.timer = null;
                }
                
                Validate(this.refIndex + 8, false);
                
                this.AddressChange();
            }
        }
        ,
    OnKeyUp:
        function(e)
        {
            if (this.inputElement.value != this.inputValue)
            {
                if (this.timer)
                {
                    clearTimeout(this.timer);
                }
                
                Validate(this.refIndex + 8, false);
                
                this.inputValue = this.inputElement.value;
                this.timer      = setTimeout(this.fAddressChange, 400);
           }
       }
        ,
    AddressChange:
        function()
        {
            this.timer = null;

            if (this.requestPending)
            {
                this.timer = setTimeout(this.fAddressChange, 300);
            }
            else
            {
                this.inputValue     = this.inputElement.value;
                this.requestPending = true;
                Validate(this.refIndex + 8, false);
 
                new Ajax.Request(
                    'MAjax.asp',
                    {
                    onSuccess:
                        this.OnSuccess.bind(this),
                    onComplete:
                        this.OnComplete.bind(this),
                    parameters:
                        { R: this.refIndex, V: this.inputValue }
                    }
                );
            }
            
        }
        ,
    OnComplete:
        function(transport)
        {
            this.requestPending = false;
        }
        ,
    OnSuccess:
        function(transport)
        {
            var response = transport.responseText;
            Validate(this.refIndex + 8, !!parseInt(response));
        }
    }
);

//]]>
</SCRIPT>
 
Everything looks o.k. It might be that the Heathrow Airport option's value is not 0.

Try this, and see what you get:
Code:
function DDPaddrTypeChanged(control)
{
    DDPaddrTypeIndex = control.selectedIndex;
    if (HandlePickup) HandlePickup.destruct();
    HandlePickup     = null;
    Validate(1, false);
    $("PAinput").hide();
    $("PAshow").innerHTML = "";
    defPickupIndex   = -1;
 
    SetPaddrType(true);
[red]alert(control.value);[/red]
if(control.value=="0"){ //I'm assuming the value is 0, based on what you have
alert('Repopulating');
Repopulate_DD2();  // Call your function to populate your dropdown.
}
}

Alter it,and run it, and see what value comes up in the popup that should hopefully appear.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
infact all the options in that drop down menu

Local Address
Any Address
Heathrow Airport
Heathrow Hotel

all produce a blank value. am i right to assume that we just need to assign some values to these selections?
 
also thought i might add that on firefox the alert actually displays the chosen value..

when you click Heathrow Airport, the alert displays 'Heathrow Airport'

on internet explorer it displays as blank
 
Odd, perhaps we can use the selectedIndex instead.

try alerting control.selectedIndex see what value it has when Heathrow Airport is chosen, and use that in the If statement.

alert(control.selectedIndex);


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
we are definately getting very close. i have found that the selectedIndex value is just a counter:

Heathrow Airport = 3
Heathrow Hotel = 4

So, what I have done is the following:

Code:
var AS_Airport =
    {
    group :
        "Heathrow Airport",

    premise:
        "Flight Number (eg VS401 Dubai)",

    shortcuts :
        [           

        ["HEATHROW TERMINAL 1", "Heathrow Airport - Terminal 1"],
        ["HEATHROW TERMINAL 3", "Heathrow Airport - Terminal 3"],
        ["HEATHROW TERMINAL 4", "Heathrow Airport - Terminal 4"],
        ["HEATHROW TERMINAL 5", "Heathrow Airport - Terminal 5"]
    
        ], 
    dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [
            
            ["Standard Saloon",  [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
            ["Executive Saloon",  [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
            ["Estate Vehicle",  [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
            ["People Carrier",  [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
            ["8 Seater Vehicle",  [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]
     
    
            ]
     
    };



var AH_Hotel = 
    {
    group :
        "Heathrow Hotel",

    premise:
        "Room Number (if known)",

    shortcuts :
        [           

        ["ARORA LHR", "Arora Park Hotel Heathrow, Old Bath Road, Poyle, SL3 0NZ"],
        ["CROWNE PLAZA LHR", "Crowne Plaza Heathrow Hotel, Stockley Road, West Drayton, UB7 9BW"],
        ["MARRIOTT WINDSOR LHR", "Heathrow & Windsor Marriott, Ditton Road Langley, SL3 8PT"],
        ["COMFORT INN LHR", "Heathrow Comfort Inn Hotel, Shepiston Lane, Hayes, UB3 1LP"],
        ["COPTHORNE SLOUGH LHR", "Heathrow Copthorne Slough Windsor, 400 Cippenham Lane, Slough, SL1 2YE"],
        ["SHERATON LHR", "Heathrow Sheraton Hotel, Colnbrook By Pass, West Drayton, UB7 0HJ"],
        ["THISTLE LHR", "Heathrow Thistle Hotel, Bath Road, Longford, West Drayton, UB7 0EQ"],
        ["HILTON LHR", "Hilton Hotel Heathrow, Terminal 4, Scylla Road, TW6 3AF"],
        ["HOLIDAY INN LHR", "Holiday Inn London Heathrow, Bath Road, Corner Sipson Way, West Drayton, UB7 0DP"],
        ["HOLIDAY INN AERIAL", "Holiday Inn Aerial Hotel, 118 Bath Road, Hayes, UB3 5AJ"],
        ["HOLIDAY INN M4", "Holiday Inn M4 Heathrow Hotel, M4 Jnct 4, Sipson Road, UB7 9DJ"],
        ["IBIS LHR", "Ibis London Heathrow Hotel, 112 Bath Road, Hayes, UB3 5AL"],
        ["JURYS INN LHR", "Jurys Inn Hotel, Eastern Perimeter Road, Hatton Cross, TW6 2SR"],
        ["MARRIOTT LHR", "Marriott Heathrow Hotel, Bath Road, Harlington, Hayes, UB3 5AN"],
        ["NOVOTEL LHR", "Novotel Heathrow Hotel, Cherry Lane, West Drayton, UB7 9HD"],
        ["PARK INN LHR", "Park Inn Heathrow Hotel, Bath Road, West Drayton, UB7 0DU"],
        ["RADISSON LHR", "Radisson Edwardian Hotel, 140 Bath Road, Hayes, UB3 5AW"],
        ["RENAISSANCE LHR", "Renaissance London Heathrow Hotel, Bath Road, Hounslow, TW6 2AQ"],
        ["SHERATON SKYLINE LHR", "Sheraton Skyline Hotel, Bath Road, Hayes, UB3 5BP"],
        ["SOFITEL LHR", "Sofitel Heathrow Hotel, Terminal 5, Heathrow Airport, TW6 2GD"] 

    
        ], 
    dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [
            
            ["Standard Saloon",     ["01. Saloon [SAL]"]],
            ["Executive Saloon",     ["07. Executive Saloon [EXEC-SAL]"]],
            ["Estate Vehicle",     ["02. Estate [EST]"]],
            ["People Carrier",     ["03. 5 Seater [5ST]"]],
            ["8 Seater Vehicle",     ["06. 8 Seater [8ST]"]]
     
    
            ]
     
    };






var AddressShortcuts = [AS_Airport,AH_Hotel];



function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
//run a loop to populate drop down
for(var i=0; i<=AS_Airport.dd2options.length-1;i++){
var optn = document.createElement("OPTION");
optn.text = AS_Airport.dd2options[i];
optn.value = i;
dd2.options.add(optn);
}

}



function DDPaddrTypeChanged(control)
{
    DDPaddrTypeIndex = control.selectedIndex;
    if (HandlePickup) HandlePickup.destruct();
    HandlePickup     = null;
    Validate(1, false);
    $("PAinput").hide();
    $("PAshow").innerHTML = "";
    defPickupIndex   = -1;
 
    SetPaddrType(true);
if(control.selectedIndex="3"){ 
Repopulate_DD2();  
}
if(control.selectedIndex="4"){ 
Repopulate_DD2();  
}
}

1st problem

When you select any of the Pickup Address options (Local Address, Any Address, Heathrow Airport, Heathrow Hotel), that value automatically turns into Heathrow Hotel (ie last selected index 4)

2nd problem

All the pickup address options are sending the Heathrow Airport values to the second drop down menu, ideally I would want the following:

Code:
IF selected index=3 (Heathrow Airport) THEN drop down 2 VALUES ARE
["Standard Saloon",  [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
            ["Executive Saloon",  [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
            ["Estate Vehicle",  [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
            ["People Carrier",  [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
            ["8 Seater Vehicle",  [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]

IF selected index=anything else THEN drop down 2 values are
["Standard Saloon",     ["01. Saloon [SAL]"]],
            ["Executive Saloon",     ["07. Executive Saloon [EXEC-SAL]"]],
            ["Estate Vehicle",     ["02. Estate [EST]"]],
            ["People Carrier",     ["03. 5 Seater [5ST]"]],
            ["8 Seater Vehicle",     ["06. 8 Seater [8ST]"]]


Also I noticed that when the drop down did repopulate, it was not displaying the option names as:

Standard Saloon
Executive Saloon
Estate Vehicle
People Carrier
8 Seater Vehicle

The 2nd part of each i.e 01. Saloon [SAL]", "30. Meet & Greet [M&G] should be the value of the option (invisible to the user). what the drop down was doing was placing those parts as the drop down options, like this:

01. Saloon [SAL]", "30. Meet & Greet [M&G]
02. Estate [EST]", "30. Meet & Greet [M&G]

etc

that format is incorrect.

here is the website:

http://londonheathrowcars-accounts/webbookercc/oneform.asp

 
We are getting close.

1st problem

When you select any of the Pickup Address options (Local Address, Any Address, Heathrow Airport, Heathrow Hotel), that value automatically turns into Heathrow Hotel (ie last selected index 4)
Yes, because you ar setting the selectedIndex to 4 and then populating the drop down.
if(control.selectedIndex="3"){
Repopulate_DD2();
}
if(control.selectedIndex="4"){
Repopulate_DD2();
}
You are still missing the second equal sign that denotes comparison instead of the assignment you currently have.
So:
Code:
if(control.selectedIndex=[red]=[/red]"3"){
Repopulate_DD2();  
}
if(control.selectedIndex=[red]=[/red]"4"){
Repopulate_DD2();  
}


2nd problem

All the pickup address options are sending the Heathrow Airport values to the second drop down menu, ideally I would want the following:

This will be solved when you fix the equal signs.

Also I noticed that when the drop down did repopulate, it was not displaying the option names as:

Standard Saloon
Executive Saloon
Estate Vehicle
People Carrier
8 Seater Vehicle

The 2nd part of each i.e 01. Saloon [SAL]", "30. Meet & Greet [M&G] should be the value of the option (invisible to the user). what the drop down was doing was placing those parts as the drop down options, like this:
Just a small change is required for that:

Code:
...
optn.text = AS_Airport.dd2options[i][red][0][/red];
optn.value = i;
dd2.options.add(optn);
...



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
ok i understand the changes you have just made. they make perfect sense to me.

to do some testing I have added the values DEFAULT, AIRPORT, and HOTEL to the drop down values for the second menu.

here is the code

Code:
var AS_Airport =
    {
    group :
        "Heathrow Airport",

    premise:
        "Flight Number (eg VS401 Dubai)",

    shortcuts :
        [           

        ["HEATHROW TERMINAL 1", "Heathrow Airport - Terminal 1"],
        ["HEATHROW TERMINAL 3", "Heathrow Airport - Terminal 3"],
        ["HEATHROW TERMINAL 4", "Heathrow Airport - Terminal 4"],
        ["HEATHROW TERMINAL 5", "Heathrow Airport - Terminal 5"]
    
        ], 
    dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [
            
	    ["Please Select . . .",     [" "]],
            ["AIRPORTStandard Saloon (4 passengers, 2 suitcases, 2 carry ons)",  [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
            ["AIRPORTExecutive Saloon (4 passengers, 2 suitcases, 2 carry ons)",  [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
            ["AIRPORTEstate Vehicle (4 passengers, 4 suitcases, 4 carry ons)",  [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
            ["AIRPORTPeople Carrier (5 passengers, 5 suitcases, 5 carry ons)",  [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
            ["AIRPORT8 Seater Vehicle (8 passengers, 8 suitcases, 8 carry ons)",  [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]
     
    
            ]
     
    };



var AH_Hotel = 
    {
    group :
        "Heathrow Hotel",

    premise:
        "Room Number (if known)",

    shortcuts :
        [           

        ["ARORA LHR", "Arora Park Hotel Heathrow, Old Bath Road, Poyle, SL3 0NZ"],
        ["CROWNE PLAZA LHR", "Crowne Plaza Heathrow Hotel, Stockley Road, West Drayton, UB7 9BW"],
        ["MARRIOTT WINDSOR LHR", "Heathrow & Windsor Marriott, Ditton Road Langley, SL3 8PT"],
        ["COMFORT INN LHR", "Heathrow Comfort Inn Hotel, Shepiston Lane, Hayes, UB3 1LP"],
        ["COPTHORNE SLOUGH LHR", "Heathrow Copthorne Slough Windsor, 400 Cippenham Lane, Slough, SL1 2YE"],
        ["SHERATON LHR", "Heathrow Sheraton Hotel, Colnbrook By Pass, West Drayton, UB7 0HJ"],
        ["THISTLE LHR", "Heathrow Thistle Hotel, Bath Road, Longford, West Drayton, UB7 0EQ"],
        ["HILTON LHR", "Hilton Hotel Heathrow, Terminal 4, Scylla Road, TW6 3AF"],
        ["HOLIDAY INN LHR", "Holiday Inn London Heathrow, Bath Road, Corner Sipson Way, West Drayton, UB7 0DP"],
        ["HOLIDAY INN AERIAL", "Holiday Inn Aerial Hotel, 118 Bath Road, Hayes, UB3 5AJ"],
        ["HOLIDAY INN M4", "Holiday Inn M4 Heathrow Hotel, M4 Jnct 4, Sipson Road, UB7 9DJ"],
        ["IBIS LHR", "Ibis London Heathrow Hotel, 112 Bath Road, Hayes, UB3 5AL"],
        ["JURYS INN LHR", "Jurys Inn Hotel, Eastern Perimeter Road, Hatton Cross, TW6 2SR"],
        ["MARRIOTT LHR", "Marriott Heathrow Hotel, Bath Road, Harlington, Hayes, UB3 5AN"],
        ["NOVOTEL LHR", "Novotel Heathrow Hotel, Cherry Lane, West Drayton, UB7 9HD"],
        ["PARK INN LHR", "Park Inn Heathrow Hotel, Bath Road, West Drayton, UB7 0DU"],
        ["RADISSON LHR", "Radisson Edwardian Hotel, 140 Bath Road, Hayes, UB3 5AW"],
        ["RENAISSANCE LHR", "Renaissance London Heathrow Hotel, Bath Road, Hounslow, TW6 2AQ"],
        ["SHERATON SKYLINE LHR", "Sheraton Skyline Hotel, Bath Road, Hayes, UB3 5BP"],
        ["SOFITEL LHR", "Sofitel Heathrow Hotel, Terminal 5, Heathrow Airport, TW6 2GD"] 

    
        ], 
    dd2options : //Add your heathrow specific options to your heathrow object, or to another object
        [

       	    ["Please Select . . .",     [" "]],
            ["HOTELStandard Saloon (4 passengers, 2 suitcases, 2 carry ons)",     ["01. Saloon [SAL]"]],
            ["HOTELExecutive Saloon (4 passengers, 2 suitcases, 2 carry ons)",     ["07. Executive Saloon [EXEC-SAL]"]],
            ["HOTELEstate Vehicle (4 passengers, 4 suitcases, 4 carry ons)",     ["02. Estate [EST]"]],
            ["HOTELPeople Carrier (5 passengers, 5 suitcases, 5 carry ons)",     ["03. 5 Seater [5ST]"]],
            ["HOTEL8 Seater Vehicle (8 passengers, 8 suitcases, 8 carry ons)",     ["06. 8 Seater [8ST]"]]			
     
    
            ]
     
    };






var AddressShortcuts = [AS_Airport,AH_Hotel];



function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
//run a loop to populate drop down
for(var i=0; i<=AS_Airport.dd2options.length-1;i++){
var optn = document.createElement("OPTION");
optn.text = AS_Airport.dd2options[i][0];
optn.value = i;
dd2.options.add(optn);

}

}



function DDPaddrTypeChanged(control)
{
    DDPaddrTypeIndex = control.selectedIndex;
    if (HandlePickup) HandlePickup.destruct();
    HandlePickup     = null;
    Validate(1, false);
    $("PAinput").hide();
    $("PAshow").innerHTML = "";
    defPickupIndex   = -1;
 
    SetPaddrType(true);
if(control.selectedIndex=="3"){ 
Repopulate_DD2();  
}
if(control.selectedIndex=="4"){ 
Repopulate_DD2();  
}
}

please see the page here:

http://londonheathrowcars-accounts.com/webbookercc/oneform.asp

First Problem

when you load the form you can see that the values in Vehicle Type are set to DEFAULT, which is correct.

when you choose 'Heathrow Airport' on the Pickup Address, you can see that the Vehicle Type values become AIRPORT, which is also correct.

however, when you choose 'Heathrow Hotel', the Vehicle Type values stay as AIRPORT. they are not changing to HOTEL values like they should.

Second Problem

I know that as a fixed price we charge £42.00 from SW1A 1AA (Buckingham Palace) to Heathrow Airport Terminal 5 for a Saloon Car. When you try this out on the form it shows a price of £62.00. This is because the option of the drop down menu is automatically increasing by 1 value.. it is actually retreving the price for an Executive Saloon when you choose Standard Saloon.

this is the order or the vehicle types

Standard Saloon
Executive Saloon
Estate Vehicle
People Carrier
8 Seater Vehicle

so if I choose Estate Vehicle.. it will retreive the People Carrier price. not sure why this is happening.

it may be worth showing you the code for the vehilce type drop down menu and also the onclick event for it

Code:
<select id="DDvehAttr" class="FormField" onchange="DDvehAttrChanged(this)" >
              <option value="-2">Please Select . . .</option>
<%
              for (i=0; i < vehAttr.length; i++)
              {%>
              <option value="<% = i %>"><% = vehAttr[i] %></option>
              <%}
%>
            </select>

Code:
function DDvehAttrChanged(control)
{
    vehAttribIndex = Number(control.options[control.selectedIndex].value);
    Validate(3, vehAttribIndex >= -1);
}

can you see anything obvious that is causing these 2 problems?

 
First Problem

when you load the form you can see that the values in Vehicle Type are set to DEFAULT, which is correct.

when you choose 'Heathrow Airport' on the Pickup Address, you can see that the Vehicle Type values become AIRPORT, which is also correct.

however, when you choose 'Heathrow Hotel', the Vehicle Type values stay as AIRPORT. they are not changing to HOTEL values like they should.
It stays because you aren't changing them back, they won't automatically reset, you need to do it specifically. Either with a function or directly in there.

Code:
if(control.selectedIndex=="4"){
Repopulate_DD2();  
}
else{
defaultpopulate_DD2();
}
}

You have all the information to repopulate it again using the other function as a guide.

For the second one, perhaps if you look at where its getting the rates from, and how its getting the rates, you and find out why its selecting the next one up. Perhaps the numbering for the rates has an issue. Sorry I can't be more specific though.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
hi, you are right. i have now fixed propblem 1.

i plan on now adding an alert to show what exactly my vehicle type dropdnw is sending to my database. from there i should be able to fix it.. i hope.

thanks you so much. i may post again if i cant get it working but i will try my best to get it working and post either way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top