I have this line of code that will replace special character in php:
<?php echo str_replace(" +12,00$,"1200",$this->htmlEscape($_image->getLabel())) ?>" />
for this to work as i need, also the jQuery will have to include this code in other call:
jQuery("#productImg" + optionValueText.replace(' +12,00€','1200')).fadeIn('slow');
This will outpout 1200
and it will work good to add a span id for an image to load.
But i will have multiple prices, so i need automatic to do the work.
I need to make both codes to remove white space in the beggining and characters
+
,
€
from the price so allways it will display the price as 1200,4400,3399 etc.
For php i think i can do it if i play some time with the code but for jQuery line also?
Can somebody provide both codes please?
Thank you very much for your kind help!
EDIT: the full php code that will load the image:
<a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=999,height=999,left=666,top=333,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;">
<span style="margin-top:-212px;"> <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" alt="no image" id="productImg<?php echo str_replace(" +12,00€","1200",$this->htmlEscape($_image->getLabel())) ?>" /></a></span>
and the jQuery that on dropdown change will control what image to hide and show.
jQuery(document).ready(function() {
// On document ready hide all images first
jQuery(".product-image2 img").hide();
jQuery("#off").hide();
jQuery("#productImgDefault").show();
jQuery("#<?=$colour_select_id ?>").change(function() {
// Hide all images on slect element change action
jQuery(".product-image img").hide();
jQuery(".product-image2 img").hide();
jQuery("#productImgDefault").hide();
jQuery(".product-image .mousetrap").hide();
// Get the value of selected option
var optionValue = jQuery(this).attr('value');
// Just a test to see if you're getting option value
// alert(optionValue);
// Get the content (aka inner HTML) of selected option
var optionValueText = jQuery.trim(jQuery('#<?=$colour_select_id ?> :selected').text());
// Just a test to see if you're getting right selected option inner text
// alert(optionValueText);
// alert('Selected option has value: ' + optionValue + ' and inner text: ' + optionValueText);
// Show the image based on selected value
// Whatch out, case sensitive...
if(optionValueText == "-- choose --") {
jQuery(".product-image .mousetrap").show();
jQuery("#on").fadeIn('slow');
jQuery("#off").hide();
jQuery("#productImgDefault").fadeIn('slow'); } else { jQuery("#productImg" + optionValueText.replace(' +12,00€','1200')).fadeIn('slow');
jQuery("#off").fadeIn('slow');
jQuery("#on").hide();
}
});
});