Hello,

I have one input field that is collecting some information like this:

<label>Tax Rate</label><br><input type="text" class="input" name="taxrate" id="taxrate" onblur=" return getTaxrate()"  value="<? echo $row['taxrate'] ?>">

what I am wanting to do is onblur convert from say 7.63 to .0763 for the tax rate.

I am only using one input field for this.

The JS I tried to use:

<script type="text/javascript">
function  getTaxrate() {
var gettax = document.getElementById('taxrate').value;
    {
    ans = (gettax * 100);
    outp = ans;
    }
  document.getElementById('taxrate').innerHTML = outp;
    } 
</script>

how can I get it to overwrite or automatically convert this?

I solved it...

<script type="text/javascript">
function  getTaxrate() {
var gettax = document.getElementById('taxrate').value;
    {
    ans = (gettax / 100);
    outp = ans.toFixed(4);
}

  document.getElementById('taxrate').value = outp; 
} 
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.