0

I am trying to execute the below code but it is not giving me any output when i save this as *.html file and execute it. I know this code works for sure as i have tried it on different html editors trying to simulate and it is giving me desired output. Here is a step by step procedure of what i did

  1. Written the code using the real time preview on http://www.onlinehtmleditor.net/. When i give inputs and click "Calculate". It gives me desired result

  2. Copied the same code in notepad and saved the file as *.html

  3. Now when i open this *.html file and input the numbers and click "Calculate". It is not dispalying any result

I am using IE 9 and wondering if it is because of the browser. I have a similar code for some other program which executes fine when i do the same way. I am perplexed. Kindly suggest and guide me please.

<html>
<body>
<br/> 
<font face = "georgia">
  <font color = "Blue"> Barometric reading </font>(m Hg)<br/>
  <input type="number" id="txt1" name="text1" /><br> 
  <br/><font color = "Blue">Difference in height in two limbs </font>(m)<br/>
  <input type="number" id="txt2" name="text2"><br>
  <br/> <font color = "Blue"> Fluid in manometer </font><br/>
  <select id="densityopt">
    <option value="1000">Water</option>
    <option value="13640">Mercury</option>
    <option value = "826">Red Gage Oil</option>
    <option value = "876.50">Benzene</option>
  </select>
  <br/><br/>
  <button onclick="myFunction()">Calculate</button>
  <p id="demo"></p>
  <script>
    function myFunction() {
      var a = document.getElementById("txt1").value;
      var b = document.getElementById("txt2").value;
      var i = document.getElementById("densityopt");
      var c = i.options[i.selectedIndex].value;
      var den = i.options[i.selectedIndex].text;
      var x = +a + +b;
      var y = +c * 9.79;
      var z = +y * +x;
      var z1 = +z / 1000;
      var z2 = Math.round(z1 * 100) / 100;
        document.getElementById("demo").innerHTML = '<br/><b><font color = "Green">Pressure of the fluid = </font></b>' + z2 + ' kPa'+'<br/><br/><b><i> This is how we solved !<br/></i></b>' + '<br/>Pressure of the fluid = P<sub>fluid</sub> = &#961;<sub>' + den + '</sub> g h<sub>atm</sub> +  &#961;<sub>' + den + '</sub> g h<sub>diff</sub>' + '<br>P<sub>fluid</sub> = &#961;<sub>' + den + '</sub> g ( h<sub>atm</sub> + h<sub>diff</sub> )<br>P<sub>fluid</sub> = ' + c + ' kg/m<sup>3</sup> x 9.79 m/sec<sup>2</sup> (' + a + 'm + ' + b + 'm )<br>P<sub>fluid</sub> = ' + z1 + ' x 10<sup>3</sup> N/m<sup>2</sup> = ' + z2 + ' kPa' + '<br><br><i><font color = "Grey"> &#961;<sub>' + den + '</sub> = Density of the fluid in manometer<br>g = Gravitational constant</i>' ;
    }

  </script>
</font>
</body>
</html>
RobG
  • 134,457
  • 30
  • 163
  • 204

0 Answers0