Thursday, 15 July 2010

javascript - Cannot get the dependent dropdown value from region dropdown -



javascript - Cannot get the dependent dropdown value from region dropdown -

i show geozone in registration business relationship step dropdown menu, zone (region). value of geozone dependent client take in zone (region).

the picture

in process, did modifications controller, view, including controller. in pic below :

the geozone field kotamadya/kabupaten. when take part aceh, geozone field not refreshed.

error message

i got error message below :

syntaxerror: unexpected token < ok <br /> <b>fatal error</b>: phone call fellow member function getgeozonesbyzoneid() on non-object in <b> /home/........../catalog/controller/account/register.php </b> on line <b>513</b><br /> the code

in ../controller/account/register.php, added modifications below :

public function zone() { $json = array(); $this->load->model('localisation/zone'); $geozone_info = $this->model_localisation_zone->getzone($this->request->get['zone_id']); if($geozone_info) { $this->load->model('localisation/geo_zone'); $json = array( 'country_id' => $geozone_info['country_id'], 'name' => $geozone_info['name'], 'code' => $geozone_info['code'], 'zone' => $geozone_info['zone_id'], 'geozone' => $this->model_localisation_geozone->getgeozonesbyzoneid($this->request->get['zone_id']), 'status' => $geozone_info['status'] ); } $this->response->setoutput(json_encode($json)); }

line 513 :

'geozone' => $this->model_localisation_geozone->getgeozonesbyzoneid($this->request->get['zone_id'])

i don't know what's wrong getgeozonesbyzoneid function, because think write function correctly in ../model/localisation/geo_zone.php below :

<?php class modellocalisationgeozone extends model { public function getgeozone($zone_id) { $query = $this->db->query("select * " . db_prefix . "geo_zone geo_zone_id = '" . (int)$geo_zone_id . "'"); homecoming $query->row; } public function getgeozonesbyzoneid($zone_id) { $geozone_data = $this->cache->get('geozone.' . (int)$zone_id); if (!$geozone_data) { $query = $this->db->query("select * " . db_prefix . "zone_to_geo_zone zone_id = '" . (int)$zone_id . "'"); $geozone_data = $query->rows; $this->cache->set('geozone.' . (int)$zone_id, $geozone_data); } homecoming $geozone_data; } } ?>

and added javascript register.tpl in view below :

$('select[name=\'zone_id\']').bind('change', function(event, first_time) { $.ajax({ url: 'index.php?route=account/register/zone&zone_id=' + this.value, datatype: 'json', beforesend: function() { $('select[name=\'zone_id\']').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>'); }, complete: function() { $('.wait').remove(); }, success: function(json) { var html = '<option value=""><?php echo $text_select; ?></option>'; var selected = false; if (json['geozone'] && json['geozone'] != '') { (i = 0; < json['geozone'].length; i++) { html += '<option value="' + json['geozone'][i]['geo_zone_id'] + '"'; if (json['geozone'][i]['geo_zone_id'] == '<?php echo $geo_zone_id; ?>') { html += ' selected="selected"'; selected = true; } html += '>' + json['geozone'][i]['name'] + '</option>'; } } else { html += '<option value="0" selected="selected"><?php echo $text_none; ?></option>'; } $('select[name=\'geo_zone_id\']').html(html); if(typeof first_time === "undefined" && selected) { $("#register_details_form").validate().element('#register_details_form select[name="geo_zone_id"]'); } }, error: function(xhr, ajaxoptions, thrownerror) { alert(thrownerror + "\r\n" + xhr.statustext + "\r\n" + xhr.responsetext); } }); }); $('select[name=\'zone_id\']').trigger('change', ['first_time']);

anyone can help me resolve issue? or maybe have same experiences me , willing share solutions me?

thanks before in advance.

use model_localisation_zone (defined variable) instead of model_localisation_geozone (not defined), or create sure latter defined.

javascript json opencart

No comments:

Post a Comment