Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A few problems I see in your code: </p> <ol> <li>In HTML you cannot have <code>id</code> and <code>name</code> attributes with spaces (<a href="http://www.w3.org/TR/html4/types.html#type-id" rel="nofollow">http://www.w3.org/TR/html4/types.html#type-id</a>)</li> <li>You are calculating the <code>bmi</code> but aren't assigning it to the form element. </li> <li>You are missing closing brace on the javascript <code>calc()</code> function.</li> </ol> <p>The solution would be to fix the id attribute first, for e.g you could use camel case notation like follows: </p> <pre><code>&lt;form id="bmi" action="main.php" method="post"&gt; &lt;p&gt;Enter your height(in inches):&lt;/p&gt;&lt;input type="text" id="heightBox" name="heightBox"&gt; &lt;p&gt;Enter your weight(in pounds):&lt;/p&gt;&lt;input type="text" id="weightBox" name="weightBox"&gt; &lt;input type="hidden" id="bmi" name="bmi"&gt; &lt;input type="submit" value="Calculate" id="calcButton" name="calcButton" onClick="calc()"&gt; &lt;/form&gt; </code></pre> <p>Update the javascript like follows:</p> <pre><code>function calc() { // get variables from textboxes var height=document.getElementById('heightBox').value; var weight=document.getElementById('weightBox').value; var bmi=document.getElementById('bmi'); // calculate BMI weight/=2.2; height/=39.37; bmi.value=Math.round(weight/(height*height)); } </code></pre> <p>Another point to note is that you are using <code>mysql_</code> extensions which are deprecated. You want to start using <a href="http://php.net/manual/en/book.mysqli.php" rel="nofollow">mysqli</a> or <a href="http://php.net/manual/en/book.pdo.php" rel="nofollow">PDO</a> instead. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload