if u see javascript don't edit because its related with magento. thank you!
i have called a phtml script under price box in product view page with a validation function this is the phtml :
<script type="text/javascript">
//<![CDATA[
$$('#product-price-<?php echo Mage::registry('current_product')->getId(); ?>').each (function(elem){
$(elem).hide();
});
$('product-price-<?php echo Mage::registry('current_product')->getId(); ?>').show();
var Cp = document.getElementById('product-price-<?php echo Mage::registry('current_product')->getId(); ?>');
Cp.innerHTML = '$ <input type="text" class="input-text price" name="custom_price" style="width:auto;" value="<?php echo Mage::registry('current_product')->getPrice(); ?>" onchange="onChangeCP(this);"/></span><input type="hidden" id="custom_price_total" name="custom_price_total" value="<?php echo Mage::registry('current_product')->getPrice(); ?>">';
<?php
$product = Mage::getModel('catalog/product')->load(Mage::registry('current_product')->getId());
$allowCustomPrice = $product->getAttributeText('allow_customprice');
$minPrice = $product->getMinPrice(); //getAttributeText('min_price');
?>
function changeCustomPrice(el){
adviceBlock=$(el).up('span').down('.validation-advice');
if(el.value.replace(',','.')>=<?php echo $minPrice; ?>){
if(adviceBlock){
adviceBlock.remove();
el.removeClassName('validation-failed');
}
}else{
if(!adviceBlock){
el.insert({after:'<div class="validation-advice">The price should be equal or greater than <?php echo $minPrice; ?>.</div>'});
el.addClassName('validation-failed');
}
}
optionsPrice.productPrice=el.value;
optionsPrice.reload();
}
optionsPrice.formatPrice=function(price){
$('custom_price_total').value=price;
return formatCurrency(price,optionsPrice.priceFormat);
};
//]]>
</script>
this script hide the span that displays the price then it draw a input box with the price so that the client enter his price that should be greater than the mean price; if it s less then it draw an error.
when clicked in add to cart button the damn function doesn't execute and nothing is done !
if this method is wrong then how can i hide the span and add the input in product view using magento (php/...)