Question: i am working on javascript to create weight conversion . but unfortunately i am not getting correct outut rather then i am getting **NaN** in my required text fields

```js
<script>
function Convert(valNum) {
  document.getElementById("outputPounds").innerHTML=valNum*2.2046;
  document.getElementById("outputGrams").innerHTML=valNum*1000;
  document.getElementById("outputMilligrams").innerHTML=valNum*1000000;
  document.getElementById("outputUsTons").innerHTML=valNum*0.0011023;
  document.getElementById("outputOunces").innerHTML=valNum*35.274;
}
</script>
```

```html
<form name="Weightconverter">
  <fieldset class="container">
  <label for="enterWeight" >Enter Weight in Kilogram: </label>
  <input type="text" id="kgid" name="enterWeight"/>
  <input  type="button" id="enterWeight" style="background-color:#069; width:100px; padding:5px; text-align:center" value="Convert"  onClick="Convert(this.value)"/>
  </fieldset>
        </p>
        <div class="container">
  <p>Pounds: <span id="outputPounds"></span></p>
  <p>Grams: <span id="outputGrams"></span></p>
  <p>Milligrams: <span id="outputMilligrams"></span></p>
  <p>UsTons: <span id="outputUsTons"></span></p>
  <p>Ounces: <span id="outputOunces"></span></p>
        </div>
```

Answer: 
Try this:

```js

  function Convert() {
   var valNum = document.getElementById("kgid").value;

    document.getElementById("outputPounds").innerHTML=valNum*2.2046;
    document.getElementById("outputGrams").innerHTML=valNum*1000;
    document.getElementById("outputMilligrams").innerHTML=valNum*1000000;
    document.getElementById("outputUsTons").innerHTML=valNum*0.0011023;
    document.getElementById("outputOunces").innerHTML=valNum*35.274;
  }

```

```html
<form name="Weightconverter" onsubmit="return false">
  <fieldset class="container">
  <label for="enterWeight" >Enter Weight in Kilogram: </label>
  <input type="text" id="kgid" name="enterWeight"/>
    <button id="enterWeight" style="background-color:#069; width:100px; padding:5px; text-align:center" onClick="Convert()">
        Convert
    </button> 

  </fieldset>
        </p>
        <div class="container">
  <p>Pounds: <span id="outputPounds"></span></p>
  <p>Grams: <span id="outputGrams"></span></p>
  <p>Milligrams: <span id="outputMilligrams"></span></p>
  <p>UsTons: <span id="outputUsTons"></span></p>
  <p>Ounces: <span id="outputOunces"></span></p>
        </div>
```

You need to get the value of the input field, with `document.getElementById("kgid").value` and you need to add `onsubmit="return false"` to your form as well because your form doesn't suppose to send its data to anywhere.
You could also use parseInt inside your function. 

Browsers sometime interpret the number as string, input from text field, resulting in NaN

```
 <script>
function Convert(v) {
  var valNum = parseInt(v);
    //or var valNum = Number(v);
document.getElementById("outputPounds").innerHTML=valNum*2.2046;
  document.getElementById("outputGrams").innerHTML=valNum*1000;
  document.getElementById("outputMilligrams").innerHTML=valNum*1000000;
  document.getElementById("outputUsTons").innerHTML=valNum*0.0011023;
  document.getElementById("outputOunces").innerHTML=valNum*35.274;
}
</script>

```