home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (uc_shipping.js)

This example Drupal source code file (uc_shipping.js) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

apply_address, catch, country, edit, err, eval, function, if, json_address, php, type, var

The uc_shipping.js Drupal example source code

// $Id: uc_shipping.js,v 1.5.2.2 2009/07/21 14:37:18 islandusurper Exp $

/**
 * @file
 * Add autofill address functionality to shipment forms.
 */

/**
 * Autofill shipment address form from user selection.
 *
 * @param type
 *   Field prefix used to identify the address.
 * @param json_address
 *   JSON object of address data.
 */
function apply_address(type, json_address) {
  //if (json_address != "0") {
    eval("var address = " + json_address +";");
    $('#edit-' + type + '-first-name').val(address.first_name);
    $('#edit-' + type + '-last-name').val(address.last_name);
    $('#edit-' + type + '-phone').val(address.phone);
    $('#edit-' + type + '-company').val(address.company);
    $('#edit-' + type + '-street1').val(address.street1);
    $('#edit-' + type + '-street2').val(address.street2);
    $('#edit-' + type + '-city').val(address.city);
    $('#edit-' + type + '-postal-code').val(address.postal_code);

    if ($('#edit-' + type + '-country').val() != address.country) {
      $('#edit-' + type + '-country').val(address.country);
      try {
        uc_update_zone_select('edit-' + type + '-country', address.zone);
      }
      catch (err) {}
    }

    $('#edit-' + type + '-zone').val(address.zone);
  //}
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal uc_shipping.js source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.