Simple input validation and adding values to table
<p>I need to add product info from inputs to table by using jQuery library. I am trying for quite some time now, but I don't get anywhere. First I need to enter data to inputs, select appropriate radio button and than validate input fields. If there are no errors, product info should be added to table. I tried with the following code: <a href="http://jsfiddle.net/KS3sM/7/" rel="nofollow">jsFiddle</a></p>

<p>Nothing works as intended tho. What am I doing wrong?</p>

<p>JS code:</p>

<pre><code>$(document).ready(function () {

//Global variables
var productName = "";
var price = 0;
var onStack = "N/A";

$("body &gt; form").submit(function () {
    //Check if any of requested inputs is empty
    if ($("#name").val().length == 0) {
        //Missing name alert
        $("#errors").val('Missing product name');
        break;
    } else if ($("#price").val() == 0) {
        //Missing price alert
        $("#errors").val('Missing price');
        break;
    }

    //Get values from text inputs
    productName = $("#name").val();
    price = $("#price").val();

    //Check radio buttons and assign values
    if ($('input[value = "true"]'.is(':checked')) {
        onStack = "Product available";
    } else if ('input[value = "false"]'.is(':checked') {
        onStack = "Not available";
    }

    //Add values to table
    $("table tr:last").after("&lt;tr&gt;&lt;td&gt;$productName&lt;/td&gt;&lt;td&gt;$price&lt;/td&gt;&lt;td&gt;$onStack&lt;/td&gt;&lt;/tr&gt;");
    });
});
</code></pre>

<p>HTML code:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="index.js"&gt;&lt;/script&gt;
&lt;meta charset=utf-8 /&gt;
&lt;title&gt;JS Bin&lt;/title&gt;

&lt;body&gt;
    &lt;form method="" action=""&gt;
        &lt;input type="text" id="name" placeholder="Product name" /&gt;
        &lt;br /&gt;
        &lt;input type="text" id="price" placeholder="Price" /&gt;
        &lt;br/&gt;
        &lt;input type="radio" name="stack" value="true"&gt;Product available
        &lt;br /&gt;
        &lt;input type="radio" name="stack" value="false"&gt;Product not available
        &lt;br /&gt;
        &lt;input type="submit" value="Submit"&gt;
    &lt;/form&gt;
    &lt;div id="errors"&gt;&lt;/div&gt;
    &lt;br /&gt;
    &lt;table border="1"&gt;
        &lt;tr&gt;
            &lt;th&gt;Product name&lt;/th&gt;
            &lt;th&gt;Price&lt;/th&gt;
            &lt;th&gt;Stack&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
    &lt;div id="sumOnStack"&gt;Sum of available products&lt;/div&gt;
    &lt;div id="SumNotOnStack"&gt;Sum of unavailable products&lt;/div&gt;
    &lt;input type="button" id="resetForm" value="Reset form" /&gt;
    &lt;br /&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
