I have a field in html
of type text that has a currency mask.
I have to save this value to a field of type double
in the database, but I'm having trouble converting, where the value that would be after the comma is suppressed after the conversion.
HTML code:
<div class="form-group ">
<label class="control-label " for="adiantamento">
Adiantamento
</label>
<div class="input-group">
<div class="input-group-addon">
R$
</div>
<input class="form-control" type="text" id="adiantamento" name="adiantamento" onKeyPress="return(MascaraMoeda(this,'.',',',event))"/>
</div>
</div>
PHP code (I replace the comma with the dot and try to convert to double)
$adiantamento=str_replace(',','.',$_POST['adiantamento']);
$adiantamento_C=(double)$adiantamento;
Form Screen
Stringanddoubleprint