Javascript: Insurance Program
<p>Making a simple javascript program to classify users under certain insurance brackets depending on their age and marital status. The following program works, however when I test the program I cannot get the program to correctly differentiate between class 3 and class 4 insurance. Im fairly new to javascript so please excuse If I have something silly.</p>

<pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;

       &lt;meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt; Insurance Program &lt;/title&gt;

&lt;script type = "text/javascript"&gt;

function insurance(form)
{

var fname = form.firstname.value;
var sname = form.surname.value;
var age = form.age.value;
var insurance;

var marital = form.maritalstatus.value;

document.write(marital);

if (marital = 2 &amp;&amp; age &gt;= 30)
{
insurance = "Grade 1";
}

else if (marital = 1 &amp;&amp; age &gt; 30)
{
insurance = "Grade 2";
}

else if (marital = 2 &amp;&amp; age &lt; 30)
{
insurance = "Grade 3";
}

else if (marital = 1 &amp;&amp; age &lt; 30)
{
insurance = "Grade 4";
}

document.write("Thank you " + fname + " " + sname + "&lt;br&gt;");
document.write("You belong to " + insurance + " Insurance");

}

&lt;/script&gt;


&lt;/head&gt;

&lt;body&gt;

&lt;h4&gt; Insurance Program &lt;/h4&gt;

&lt;form&gt;
Enter your first-name : &lt;input type = "text" name="firstname"&gt; 
Enter your surname : &lt;input type = "text" name="surname"&gt; &lt;br&gt;
Enter your age: &lt;input type = "text" name="age"&gt; &lt;br&gt;
Select your current marital status
&lt;Select id ="maritalstatus" name = "maritalstatus"&gt;
&lt;option value = "1"&gt; Single &lt;/option&gt;
&lt;option value = "2"&gt; Married &lt;/option&gt;
&lt;/Select&gt;


&lt;input type = "submit" value = "submit" onclick="insurance(this.form)"&gt;
&lt;/form&gt;


&lt;/body&gt;
&lt;/html&gt;
</code></pre>
