Hide states when no states are shown

Dear friends, if you'd like to hide state field when they are not used you may want to adjust your OPC theme this way:
modify: /components/com_onepage/themes/YOUR OPC THEME AS SELECTED AT THE DISPLAY TAB/tabcontent.js
add new code to the very bottom:
best regards, stan
modify: /components/com_onepage/themes/YOUR OPC THEME AS SELECTED AT THE DISPLAY TAB/tabcontent.js
add new code to the very bottom:
- Code: Select all
function hideStates(prefix) {
if (!(prefix != null)) prefix = '';
var d = jQuery('#'+prefix+'virtuemart_state_id'+'_div');
if (d.length > 0) {
d.hide();
}
var d = jQuery('#'+prefix+'virtuemart_state_id'+'_input');
if (d.length > 0) {
d.hide();
}
}
function showStates(prefix) {
if (!(prefix != null)) prefix = '';
var d = jQuery('#'+prefix+'virtuemart_state_id'+'_div');
if (d.length > 0) {
d.show();
}
var d = jQuery('#'+prefix+'virtuemart_state_id'+'_input');
if (d.length > 0) {
d.show();
}
}
//var callWhenHasStates = new Array();
//var callWhenNoStates = new Array();
if (typeof addOpcTriggerer != 'undefined') {
addOpcTriggerer('callWhenHasStates', 'showStates(prefix)');
addOpcTriggerer('callWhenNoStates', 'hideStates(prefix)');
}
jQuery(document).ready(function() {
if (typeof OPCStates == 'undefined') return;
var elopc = document.getElementById('virtuemart_country_id');
var value = '';
if (elopc != null) {
if (elopc.options != null) {
value = elopc.options[elopc.selectedIndex].value;
}
else
if (elopc.value != null) {
value = elopc.value;
}
var statefor = eval('OPCStates.state_for_'+value);
if (typeof statefor == 'undefined') {
hideStates('');
}
}
var elopc = document.getElementById('shipto_virtuemart_country_id');
var value = '';
if (elopc != null) {
if (elopc.options != null) {
value = elopc.options[elopc.selectedIndex].value;
}
else
if (elopc.value != null) {
value = elopc.value;
}
var statefor = eval('OPCStates.state_for_'+value);
if (typeof statefor == 'undefined') {
hideStates('shipto_');
}
}
});
best regards, stan