0

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?

1
Contributor
1
Reply
9
Views
4 Years
Discussion Span
Last Post by patk570
0

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>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.