I have been trying to make this code to display textfield number in real-time currency format at you type it. But once the page is loaded, it give me an error message that say the following: Warning: number_format() expects parameter 1 to be double...
Please, can someone help me to fix the problem with the code. Below is my code.
<input id="source" type="text" oninput="copyData('source', 'target')" />
<?php
$num = '<span id="target" class="myDIV"></span>';
$formattedNum = number_format($num, 2);
echo $formattedNum;
?>
<script type="text/javascript">
function copyData(sourceId, targetId) {
var data = document.getElementById(sourceId).value;
document.getElementById(targetId).innerHTML = data;
}
</script>
here.
Snippet example :