Page 1 of 1

Adding auto Zipcode to zone

Posted: Sat Mar 09, 2013 6:00 pm
by jadeye
Hello everyone,

I am trying to create a free VQMod:
1. That will add zipcode per zone in zone table and view.
2. Once a customer registers, by clicking on a Country->Zone,
Post Code will be automatically filled in - since alot of people do not remember their zip codes.
3. Thus enabling the admin to group several different customer shippments together.

I need help on some JS:

1. I am trying to write a select that will load a new select with onChange function that will populate a text input:
The following select is to populate the other select:
*this is the original code from customer_form.tpl

Code: Select all

<td><select name="address[<?php echo $address_row; ?>][country_id]" 
id="address[<?php echo $address_row; ?>][country_id]"
onchange="$('select[name=\'address[<?php echo $address_row; ?>]
[zone_id]\']').load('index.php?route=sale/customer/zone&token=<?php echo $token;
 ?>&country_id=' + this.value + '&zone_id=<?php echo $address['zone_id']; ?>');">
So country_id populates zone_id.

2. Now I am trying to trigger change on zone_id in order to populate a zipcode text input so:
* I have made the necessary changed to zone table

Code: Select all

<script type="text/javascript"><!--
$('select[name=\'address[<?php echo $address_row; ?>][zone_id]\']')
.load('index.php?route=sale/customer/zone&token=<?php echo $token; ?>&country_id=<?php echo $address['country_id']; ?>
&zone_id=<?php echo $address['zone_id']; ?>').change(function() { 
$('input[name=\'address[<?php echo $address_row; ?>][postcode]\']'
.val('<?php echo $address['zone_id'] ?>'))
$('select[name=\'address[<?php echo $address_row; ?>][zone_id]\']').trigger('change');
The select zone_id is populated but does not trigger change in various ways I have tried. Any ideas??

Can anyone tell me what I am doping wrong or point me at the right direction?? O0