NOTE: This is from a Joomla component.
The Problem: When I enter, say, 4.90 into the price input box and hit save the price becomes 5, etc. I need for the val开发者_如何学编程ue to remain as entered.
I've tracked down this block of code in the form.php looks like it might be the right one, but I can't figure out what needs to change:
function toTransFloat( input )
{
value = input.value;
if ( value != null && value.length != 0 )
value = value.replace( ',' , '.' );
else
return false;
input.value = ( isNaN( parseFloat( value ) ) == false ? parseFloat( value ) : "" );
return input.value;
}
help ... ?
I doubt that changing the Joomla code is really what you need to do; I'm not familiar with Joomla, but in Drupal if you're creating a form you can define the type of data you expect. Check that the field you're checking has not been defined as an integer type of field - that may help.
If not, I'm not sure, but messing with the code from the CMS or framework that you're using is going to cause you pain when you need to upgrade in the future - and for something like this, it's almost certainly unnecessary.
精彩评论