Jump to content

[Solved/Workarounded]: How to detect browser or use multi-browser vars?


Daywalker

Recommended Posts

Prestashop-Version: 1.6.0.6

 

 

EDIT: fadeToggle(); did the trick, don't need to know the id at this point.

 

 

 

I did an onchange-event for the radio-buttons in order-carrier.tpl:

<input id="delivery_option_{$id_address}_{$option@index}" class="delivery_option_radio" type="radio" name="delivery_option[{$id_address}]" data-key="{$key}" data-id_address="{$id_address|intval}" onclick="handleClick(this)" onchange="yeon();"  value="{$key}"{if isset($delivery_option[$id_address]) && $delivery_option[$id_address] == $key} checked="checked"{/if} />

Following code works in Chrome:

function yeon() {
					
if ($('#delivery_option_8_1').is(':checked')) {
$('#abhol').show();
} else {
$('#abhol').hide();
[spam-filter];
    

but for Firefox it needs to be 4_1 not 8_1:

function yeon() {
					
if ($('#delivery_option_4_1').is(':checked')) {
$('#abhol').show();
} else {
$('#abhol').hide();
[spam-filter];
    

And I dont know about the other browsers.

 

The best thing would be if it would be possible to set:

#delivery_option_*_1

So the star could be anything.

 

I also tried detecting the browser like:

function yeon2() {
		var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;  // Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
		var isFirefox = typeof InstallTrigger !== 'undefined';   // Firefox 1.0+
		var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;   // At least Safari 3+: "[object HTMLElementConstructor]"
		var isChrome = !!window.chrome && !isOpera;              // Chrome 1+
		var isIE = /*@cc_on!@*/false || !!document.documentMode;   // At least IE6
		yeon();
		};

in combination with:

function yeon() {
		
	if (isChrom) {				
if ($('#delivery_option_8_1').is(':checked')) {
$('#abhol').show();
} else {
$('#abhol').hide();
}
}
	if (isFirefox) {				
if ($('#delivery_option_4_1').is(':checked')) {
$('#abhol').show();
} else {
$('#abhol').hide();
}
}
}

I can imagine that my coding is noob-style (sorry for that), but Im open for any suggestions.

(I don't mind putting my code into the trash)

 

I would be very happy if anyone could help me.

Thanks soo much

Edited by Daywalker (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...