Call a recursive function with different variables
<p>I am new to javascript. I am doing a feedback form where there are 12 radio buttons that need to get validated individually and a textarea will be displayed when I click a particular value.</p>

<p>Here, when I click that button, my textarea, which is in display, should be mandatory entered (eg: when I click fail option in a results question, then I should mention in which subject he failed through that textarea. something like that).</p>

<p>For this, I have written code, it's working fine with the 1st radio button, but unable to call this recursively for remaining buttons.</p>

<p>I need to call this code in a function recursively, but my variables need to get change everytime.  Like for 2nd time, I should use option2,text2, likewise in next call option3,text3, etc.</p>

<pre><code>var option = $("#form1 input[@name=radio1]:checked").val();
var text = document.getElementById("text1").value;

if (!$("#form1 input[@name=radio1]:checked").val()) {
    alert("Please fill all the fields");
    return false;
    errs++;
} else if (option == "3" &amp;&amp; trim(text) == "") {
    alert("Please enter comments.");

    return false;

}
</code></pre>

<p>This piece of code needs to be called for var option1 to option10 and same text1 to text10.  Like:</p>

<pre><code>var option2 = $("#form1 input[@name=radio2]:checked").val();
var text2 = document.getElementById("text2").value;
</code></pre>

<p>This should get called immediately of completion of first radio button.</p>

<p>Please help me out.</p>
