From af55b0c7aaa45f8f2d09118d72f4e67ebe2d806a Mon Sep 17 00:00:00 2001 From: Vikas Mayur Date: Sat, 12 Jul 2008 09:31:40 +0000 Subject: [PATCH] Implemented Ajax based feature on Country drop-down field on Step 4 Billing of One Page. Now when a user select a Country from the drop-down field it shows only associated states for this country in State field. Done by Rishi Solanki, Brajesh Patel and reviewed by Sumit Pandit. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@676138 13f79535-47bb-0310-9956-ffa450edef68 --- .../ecommerce/images/checkoutProcess.js | 38 +++++++++++++++---- .../order/OnePageCheckoutProcess.ftl | 1 - 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js b/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js index 72751bf4df..e94bd4f571 100644 --- a/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js +++ b/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js @@ -61,7 +61,8 @@ Event.observe(window, 'load', function() { Event.observe($('editBilling'), 'click', function() { if (isCartStepValidate && isShipStepValidate) { if (validateShipOption.validate()) { - setShippingOption(); + setShippingOption(); + getAssociatedBillingStateList(); displayBillingPanel(); isShipOptionStepValidate = true; } @@ -92,7 +93,10 @@ Event.observe(window, 'load', function() { }); // For Billing Address Same As Shipping - Event.observe('useShippingAddressForBilling', 'click', useShippingAddressForBillingToggel); + Event.observe('useShippingAddressForBilling', 'click', function() { + getAssociatedBillingStateList(); + useShippingAddressForBillingToggle(); + }); // Initiate Observing Edit Cart Events initCartProcessObservers(); @@ -105,6 +109,9 @@ Event.observe(window, 'load', function() { Event.observe($('shipToStateProvinceGeo'), 'focus', getAssociatedStateList); Event.observe($('shipToStateProvinceGeo'), 'blur', splitStateNameFromIds); + + // Get associate states for billing panel + Event.observe($('billToCountryGeoId'), 'change', getAssociatedBillingStateList); }); // Cart @@ -280,17 +287,17 @@ function setDataInShippingOptionCompleted() { } // Billing -function useShippingAddressForBillingToggel() { - if($('useShippingAddressForBilling').checked) { +function useShippingAddressForBillingToggle() { + $('billToStateProvinceGeoId').value = $F('shipToStateProvinceGeoId'); + if ($('useShippingAddressForBilling').checked) { $('billToAddress1').value = $F('shipToAddress1'); $('billToAddress2').value = $F('shipToAddress2'); $('billToCity').value = $F('shipToCity'); - $('billToStateProvinceGeoId').value = $F('shipToStateProvinceGeoId'); $('billToPostalCode').value = $F('shipToPostalCode'); $('billToCountryGeoId').value = $F('shipToCountryGeoId'); - Effect.BlindUp($('billingAddress'), {duration: 0.5}); + Effect.BlindUp($('billingAddress'), {duration: 0.3}); } else { - Effect.BlindDown($('billingAddress'), {duration: 0.5}); + Effect.BlindDown($('billingAddress'), {duration: 0.3}); } } @@ -549,4 +556,21 @@ function splitStateNameFromIds() { } $('shipToStateProvinceGeoId').value = geoValues[1]; } +} + +function getAssociatedBillingStateList() { + var optionList = []; + new Ajax.Request("getAssociatedStateList", + { asynchronous: false, + parameters: $('billingForm').serialize(), + onSuccess: function(transport) { + var data = transport.responseText.evalJSON(true); + stateList = data.stateList; + stateList.each(function(state) { + geoVolues = state.split(': '); + optionList.push(""); + }); + $('billToStateProvinceGeoId').innerHTML = optionList; + } + }); } \ No newline at end of file diff --git a/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl b/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl index 353ba780e5..7c39534c12 100644 --- a/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl +++ b/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl @@ -604,7 +604,6 @@ under the License. <#else> - ${screens.render("component://common/widget/CommonScreens.xml#states")}