multi condition javascript for 2 different country select lists
Hi, need a little help on coding a javascript code snippet that Ray helped me with a while back..I want to adapt on it to allow a client request.
I will describe the current checkout page then describe what I need to add.
The customer gets to the checkout page, where they can enter their address details, there is a select list for countries and a select list for delivery options. if the customer selects United Kingdom then the delivery options select list will allow the customer to select either; standard deivery, recorded delivery or special delivery. if the customer selects ANY other country then the delivery options select list is disabled (because the client doesnt want to provide any delivery options as they just want to use a default delivery charge thats automatically created elsewhere on the page based on that countries cost)...all works perfectly.....
now what I would like to add is an "alternative delivery address"....now to explain a little how this works; a customer can enter their intial address where they can order a kit (or a product and kit at the same time)...which the client sends outthe kit to the customer (this is free delivery as the kit is required to produce fingerprints for jewelry)...then the customer uses the kit sends back to the client and the client makes the jewelry and then sends the finished product to the customer...now the customer may be living in the UK so the kit gets sent to them...but the customer may want the finished product be sent to a friend or relative in another country....So I need a way to expland on my checkout form to allow for this...I am sure there are a number of ways to do this...I was even thinking of putting both the ID of the countries for both the countries select lists into a session then use PHP to calculate which is the greater delivery cost as that approach could make sense...Or I could put another checkbox on the checkout form where the customer would tick the box if they wish for the end product to be sent to an alternative address and I could use the ID of this check box to chose the session store for either the buyers address or the alternative address...I just need help to impliment this...
I am pasting and attaching the code to help with my question...
regards
Chris
Here is the javascript:
<script>
function filterTypes() {
var parent = document.getElementById("buyercountry");
var child = document.getElementById("shippingoptions");
if (parent.options[parent.selectedIndex].value != "GB") {
child.selectedIndex = 0;
child.disabled = true;
} else {
child.disabled = false;
}
}
</script>
Here is the first and second form select list segments:
<label>Country</label><select name="buyercountry" class="inputbrd [required, Required]" onchange="filterTypes()" id="buyercountry" value="<?php echo $row_rsUser['UserCountry']; ?>">
<label>Country</label><select name="shippingcountry" class="inputbrd" onchange="filterTypes()" id="shippingcountry" value="">
Heres the session variables I am setting up:
...various recordsets etc etc...
</php>
$selcountry_ShipCost = "";
if (isset($_POST["country"])) {
$selcountry_ShipCost = $_POST["country"];
}
$seltype_ShipCost = "";
if (isset($_POST["shippingoptions"])) {
$seltype_ShipCost = $_POST["shippingoptions"];
}
$cartweight_ShipCost = "1";
if (isset($_GET["CartWeight"])) {
$cartweight_ShipCost = $_GET["CartWeight"];
mysql_select_db($database_dinkydb, $dinkydb);
$query_ShipCost = sprintf("SELECT shippingcosts.* FROM shippingcosts INNER JOIN shippinglocation on ShippingLocationZone = ShippingCostZone WHERE ShippingCode = %s AND ShippingCostsType = %s AND ShippingCostsWeightTo >= %s ORDER BY ShippingCostsWeightTo ", GetSQLValueString($selcountry_ShipCost, "text"),GetSQLValueString($seltype_ShipCost, "text"),GetSQLValueString($cartweight_ShipCost, "int"));
$ShipCost = mysql_query($query_ShipCost, $dinkydb) or die(mysql_error());
$row_ShipCost = mysql_fetch_assoc($ShipCost);
$totalRows_ShipCost = mysql_num_rows($ShipCost);
?>
<?php
if (isset($_POST["country"]) && $_POST["country"] != "GB") $_POST["shippingoptions"] = "Standard Delivery";
$_GET["CartWeight"] = $DinkyCart->TotalColumn("TotalWeight");
?>
<?php
if ($row_ShipCost) $_SESSION["ShipRate"] = $row_ShipCost["ShippingCostsValue"];
?>
<?php
if (!session_id()) session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
$_SESSION["BuyerCountry"] = "".((isset($_POST["buyercountry"]))?$_POST["buyercountry"]:"") ."";
}
?>
<?php
if (!session_id()) session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
$_SESSION["ShippingCounty"] = "".((isset($_POST["shippingcounty"]))?$_POST["shippingcounty"]:"") ."";
}
?>