<div>David,</div>
<div>Thanks a lot for your kind answer.</div>
<div>I had read about &#39;storage&#39;, I hope it was mentioned it is used in D6. In D7 it may work, probably they were discouraging to use it.</div>
<div> </div>
<div>I have managed to do it using _SESSION stuff. Though it is working to some extent, still I beleive I am missing certian things here. Request to experts kindly review below code and guide me if I am correct.</div>
<div> </div>
<div>For reference kindly see <a href="http://www.netcloudsystems.com/?q=questionnaire/form/manage">http://www.netcloudsystems.com/?q=questionnaire/form/manage</a> link.</div>
<div>Corresponding code is as below.  Please let me know, if below code is correct, or it can be optimized for faster operation. I have two major concerns,</div>
<div> </div>
<div>1.   It looks to me the whole form is rebuilt when I click the &quot;Add More Caregories&quot; button, hence it takes more time to add a question category. I know it is happeing because I have a line of code <font color="#3333ff"> $form_state[&#39;rebuild&#39;] = TRUE; in add_more_categories function.</font><br>
</div>
<div> </div>
<div>2. Next the sequence of calling of functions looks strange to me.</div>
<div>First time page loads, it calls questionnaire_my_form.</div>
<div>On clicking &quot;Add More Categories&quot; button, functions are called in below sequence.</div>
<div> </div>
<div>
<ul>
<li>add_more_question_categories, category count = 1</li>
<li>questionnaire_my_form, category count = 2</li>
<li>questionnaire_category_callback, category count = 2</li></ul></div>
<div>My understanding is that with AJAX, we should be able to modify the portion of a form, not the whole form.</div>
<div>I am not able to acheive it. </div>
<div> </div>
<div>Kindly somebody help me to understand D7 AJAX stuff better.</div>
<div><br><font color="#3333ff">&lt;?php</font></div>
<div><font color="#3333ff">function questionnaire_menu() {<br>    $items = array();</font></div>
<div><font color="#3333ff">    $items[&#39;questionnaire/form/manage&#39;] = array(<br>        &#39;title&#39; =&gt; t(&#39;Manage questions&#39;),<br>        &#39;page callback&#39; =&gt; &#39;questionnaire_form&#39;,<br>
        &#39;access arguments&#39; =&gt; array(&#39;question manage&#39;),<br>        &#39;type&#39; =&gt; MENU_SUGGESTED_ITEM,<br>    );</font></div>
<div><font color="#3333ff">    return $items;<br>}</font></div>
<div><font color="#3333ff">function questionnaire_permission() <br>{<br>    return array(<br>        &#39;question manage&#39; =&gt; array(<br>        &#39;title&#39; =&gt; t(&#39;Question management&#39;),<br>        &#39;description&#39; =&gt; t(&#39;Provides question management capability&#39;),<br>
    ),<br>    );          <br>}</font></div>
<div><font color="#3333ff">function questionnaire_form() <br>{<br>    unset( $_SESSION[&#39;questionnaire&#39;][&#39;all_categories&#39;] );<br>    $_SESSION[&#39;questionnaire&#39;][&#39;all_categories&#39;] = 1;</font></div>

<div><font color="#3333ff">    return drupal_get_form(&#39;questionnaire_my_form&#39;);<br>}</font></div>
<div><font color="#3333ff">function questionnaire_my_form($form, &amp;$form_state) <br>{  <br>    $form_state[&#39;cache&#39;] = TRUE;<br>    <br>    <br>    /////////////  Start question category ////////////<br>    <br>
    $form[&#39;category_fieldset&#39;] = array(    <br>        &#39;#tree&#39; =&gt; TRUE,<br>        &#39;#title&#39; =&gt; t(&quot;Questions Categories&quot;),    <br>        &#39;#prefix&#39; =&gt; &#39;&lt;div id=&quot;category-div&quot;&gt;&#39;,    <br>
        &#39;#suffix&#39; =&gt; &#39;&lt;/div&gt;&#39;,    <br>        &#39;#type&#39; =&gt; &#39;fieldset&#39;,    <br>        //&#39;#description&#39; =&gt; t(&#39;Please enter the question categories&#39;), <br>       &#39;#collapsible&#39; =&gt; TRUE,<br>
       &#39;#collapsed&#39; =&gt; FALSE,<br>    );</font></div>
<div><font color="#3333ff">    for ($i=1; $i &lt;= $_SESSION[&#39;questionnaire&#39;][&#39;all_categories&#39;] ; $i++) <br>    {    <br>        if(isset($_SESSION[&#39;questionnaire&#39;][$i-1][&#39;catg&#39;]))<br>        {<br>
            $form[&#39;category_fieldset&#39;][$i][&#39;catg&#39;] = array(      <br>                &#39;#type&#39; =&gt; &#39;textfield&#39;,      <br>                &#39;#title&#39; =&gt; &quot;Question Category $i&quot;, <br>
                &#39;#value&#39; =&gt; $_SESSION[&#39;questionnaire&#39;][$i-1][&#39;catg&#39;],<br>            );  <br>            <br>            unset($_SESSION[&#39;questionnaire&#39;][$i-1][&#39;catg&#39;]);</font></div>

<div><font color="#3333ff">            $form[&#39;category_fieldset&#39;][$i][&#39;remove&#39;] = array(      <br>                &#39;#type&#39; =&gt; &#39;checkbox&#39;,      <br>                &#39;#title&#39; =&gt; &#39;Remove&#39;,<br>
            );  <br>        }<br>        else<br>        {<br>            $form[&#39;category_fieldset&#39;][$i][&#39;catg&#39;] = array(      <br>                &#39;#type&#39; =&gt; &#39;textfield&#39;,      <br>                &#39;#title&#39; =&gt; &quot;Question Category $i&quot;,  <br>
            );  </font></div>
<div><font color="#3333ff">            $form[&#39;category_fieldset&#39;][$i][&#39;remove&#39;] = array(      <br>                &#39;#type&#39; =&gt; &#39;checkbox&#39;,      <br>                &#39;#title&#39; =&gt; &#39;Remove&#39;,<br>
            );  <br>        }<br>        <br>    }  </font></div>
<div><font color="#3333ff">    $form[&#39;category_fieldset&#39;][&#39;add_more_categories&#39;] = array(    <br>        &#39;#type&#39; =&gt; &#39;submit&#39;,<br>        &#39;#value&#39; =&gt; t(&#39;Add More Categories&#39;),<br>
        &#39;#submit&#39; =&gt; array(&#39;add_more_question_categories&#39;),<br>        &#39;#ajax&#39; =&gt; array(      <br>        &#39;callback&#39; =&gt; &#39;questionnaire_category_callback&#39;,      <br>        &#39;wrapper&#39; =&gt; &#39;category-div&#39;,      <br>
        &#39;method&#39; =&gt; &#39;replace&#39;,      <br>        &#39;effect&#39; =&gt; &#39;fade&#39;,    <br>    ), <br>    );</font></div>
<div><font color="#3333ff">    /////////////  End question category ////////////</font></div>
<div><br><font color="#3333ff">  $form[&#39;line_break1&#39;] = array(<br>  &#39;#markup&#39; =&gt; &#39;&lt;br&gt;&#39;,<br>  );   </font></div>
<div><font color="#3333ff">    $form[&#39;submit&#39;] = array(    <br>        &#39;#type&#39; =&gt; &#39;submit&#39;,    <br>        &#39;#value&#39; =&gt; t(&#39;Save Questions &amp; Categories&#39;),  <br>    );  </font></div>

<div><font color="#3333ff">    return $form;<br>}   </font></div>
<div><font color="#3333ff">function questionnaire_category_callback($form, $form_state) <br>{  <br>    return $form[&#39;category_fieldset&#39;];<br>}</font></div>
<div><font color="#3333ff">function add_more_question_categories($form, &amp;$form_state)<br>{<br>    //Here, loop through all the category elements, if any remove checkbox is enabled, delete the corresponding row.<br>    $removed_categories = 0;<br>
    $i = 0;<br>    $j = 0;</font></div>
<div><font color="#3333ff">    while ($i &lt; $_SESSION[&#39;questionnaire&#39;][&#39;all_categories&#39;])<br>    {<br>        if($form_state[&#39;values&#39;][&#39;category_fieldset&#39;][($i + 1)][&#39;remove&#39;] == 1)<br>
        {<br>            $removed_categories++;<br>        }<br>        else<br>        {<br>            $_SESSION[&#39;questionnaire&#39;][$j][&#39;catg&#39;] = $form_state[&#39;values&#39;][&#39;category_fieldset&#39;][($i + 1)][&#39;catg&#39;];<br>
            $j++;<br>        }<br>        <br>        $i++;<br>    }<br>    <br>    if($removed_categories &gt; 0)<br>    {<br>        $_SESSION[&#39;questionnaire&#39;][&#39;all_categories&#39;] = $_SESSION[&#39;questionnaire&#39;][&#39;all_categories&#39;] - $removed_categories;<br>
    }<br>    else<br>    {<br>        $_SESSION[&#39;questionnaire&#39;][&#39;all_categories&#39;] = $_SESSION[&#39;questionnaire&#39;][&#39;all_categories&#39;] + 1;<br>    }</font></div>
<div><font color="#3333ff">    $form_state[&#39;rebuild&#39;] = TRUE;<br>}</font></div>
<div><font color="#3333ff">function questionnaire_submit($form, &amp;$form_state)<br>{<br>    drupal_set_message(&#39;Save functionality not implemented yet.&#39;);<br>    $form[&#39;#redirect&#39;] = FALSE;<br>}</font></div>

<div><font color="#3333ff">?&gt;</font></div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div><br><br> </div>
<div class="gmail_quote">On Mon, Sep 10, 2012 at 9:01 PM, Metzler, David <span dir="ltr">&lt;<a href="mailto:metzlerd@evergreen.edu" target="_blank">metzlerd@evergreen.edu</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote"><u></u><u></u><u></u>
<div lang="EN-US" vlink="blue" link="blue">
<div>
<p class="MsoNormal"><font color="navy" face="Arial"><span style="FONT-FAMILY:Arial;COLOR:navy;FONT-SIZE:10pt">I have not used form values in this way before and am unsure if they will work this way.  Typically $form_state[‘storage’] is where you might place these values that are part the form that may be modified by <u></u><u></u>ajax<u></u><u></u> callback handlers.  Have you tried using $form_state[‘storage’] instead of $form_state[‘values’] for your $all_categories data?  <u></u><u></u></span></font></p>

<p class="MsoNormal"><font color="navy" face="Arial"><span style="FONT-FAMILY:Arial;COLOR:navy;FONT-SIZE:10pt"><u></u> <u></u></span></font></p>
<p class="MsoNormal"><font color="navy" face="Arial"><span style="FONT-FAMILY:Arial;COLOR:navy;FONT-SIZE:10pt"><u></u> <u></u></span></font></p>
<p class="MsoNormal"><font color="navy" face="Arial"><span style="FONT-FAMILY:Arial;COLOR:navy;FONT-SIZE:10pt"><u></u> <u></u></span></font></p>
<div>
<div style="TEXT-ALIGN:center" class="MsoNormal" align="center"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">
<hr align="center" size="2" width="100%">
</span></font></div>
<p class="MsoNormal"><b><font face="Tahoma"><span style="FONT-FAMILY:Tahoma;FONT-SIZE:10pt;FONT-WEIGHT:bold">From:</span></font></b><font face="Tahoma"><span style="FONT-FAMILY:Tahoma;FONT-SIZE:10pt"> <a href="mailto:support-bounces@drupal.org" target="_blank">support-bounces@drupal.org</a> [mailto:<a href="mailto:support-bounces@drupal.org" target="_blank">support-bounces@drupal.org</a>] <b><span style="FONT-WEIGHT:bold">On Behalf Of </span></b>Kamal Palei<br>
<b><span style="FONT-WEIGHT:bold">Sent:</span></b> Sunday, September 09, 2012 8:44 PM<br><b><span style="FONT-WEIGHT:bold">To:</span></b> <u></u><a href="mailto:support@drupal.org" target="_blank">support@drupal.org</a><u></u><br>
<b><span style="FONT-WEIGHT:bold">Subject:</span></b> [support] Drupal 7 AHAH/AJAX issue</span></font><u></u><u></u></p></div>
<div>
<div class="h5">
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"><u></u> <u></u></span></font></p>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">Hi List<u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">I am trying to learn <u></u><u></u>ajax<u></u><u></u> stuff in Drupal 7.<u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">I want to have a simple <font color="gray"><span style="COLOR:gray">questionnaire</span></font> form. Where I will have a single textfield.<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">In that text field one will type a question category, and if he wants to type more question categories, user need to click a  button &quot;Add More Categories&quot;.<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">Please see link <a href="http://www.netcloudsystems.com/?q=questionnaire/form/manage" target="_blank">http://www.netcloudsystems.com/?q=questionnaire/form/manage</a><u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">The whole source code is at the end of this email.  When <u></u><u></u>ajax<u></u><u></u> callback fires, I want to remember how many textfields I need to add, so that when a section of form is updated in _form() hook, I can according add those many textfields.<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">I am trying to manage that using a variable &quot;$all_categories&quot; and form element $form[&#39;all_categories&#39;]  (of type value).<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">I tried many options, always I find $all_categories value is 1.   So I am unable to add more textfields. <u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">My observation is whatever I set in <u></u><u></u>ajax<u></u><u></u> callback, in _form hook api, I find value is lost.<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">Kindly guide me what I am missing.<u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">Best Regards<u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">Kamal<u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><strong><b><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt">NECS, <u></u><u></u>Bangalore<u></u><u></u></span></font></b></strong><u></u><u></u></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><em><i><font color="#000099" size="3" face="Times New Roman"><span style="COLOR:#000099;FONT-SIZE:12pt">&lt;?php</span></font></i></em><u></u><u></u></p></div>
<div>
<p class="MsoNormal"><em><i><font color="#000099" size="3" face="Times New Roman"><span style="COLOR:#000099;FONT-SIZE:12pt">function questionnaire_menu() {</span></font></i></em><i><font color="#000099"><span style="FONT-STYLE:italic;COLOR:#000099"><br>
<em><i><font face="Times New Roman"> $items = array();</font></i></em><br><em><i><font face="Times New Roman">  </font></i></em><br><em><i><font face="Times New Roman"> $items[&#39;questionnaire/form/manage&#39;] = array(</font></i></em><br>
<em><i><font face="Times New Roman"> &#39;title&#39; =&gt; t(&#39;Manage questions&#39;),</font></i></em><br><em><i><font face="Times New Roman"> &#39;page callback&#39; =&gt; &#39;questionnaire_form&#39;,</font></i></em><br>
<em><i><font face="Times New Roman"> &#39;access arguments&#39; =&gt; array(&#39;question manage&#39;),</font></i></em><br><em><i><font face="Times New Roman"> &#39;type&#39; =&gt; MENU_SUGGESTED_ITEM,</font></i></em><br>
<em><i><font face="Times New Roman"> );</font></i></em></span></font></i><u></u><u></u></p></div>
<div>
<p class="MsoNormal"><em><i><font color="#000099" size="3" face="Times New Roman"><span style="COLOR:#000099;FONT-SIZE:12pt">  return $items;</span></font></i></em><i><font color="#000099"><span style="FONT-STYLE:italic;COLOR:#000099"><br>
<em><i><font face="Times New Roman">}</font></i></em></span></font></i><u></u><u></u></p></div>
<div>
<p class="MsoNormal"><em><i><font color="#000099" size="3" face="Times New Roman"><span style="COLOR:#000099;FONT-SIZE:12pt">function questionnaire_permission() </span></font></i></em><i><font color="#000099"><span style="FONT-STYLE:italic;COLOR:#000099"><br>
<em><i><font face="Times New Roman">{</font></i></em><br><em><i><font face="Times New Roman">  return array(</font></i></em><br><em><i><font face="Times New Roman">   &#39;question manage&#39; =&gt; array(</font></i></em><br>
<em><i><font face="Times New Roman">   &#39;title&#39; =&gt; t(&#39;Question management&#39;),</font></i></em><br><em><i><font face="Times New Roman">   &#39;description&#39; =&gt; t(&#39;Provides question management capability&#39;),</font></i></em><br>
<em><i><font face="Times New Roman">   ),</font></i></em><br><em><i><font face="Times New Roman">  );          </font></i></em><br><em><i><font face="Times New Roman">}</font></i></em></span></font></i><u></u><u></u></p></div>

<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><em><i><font color="#000099" size="3" face="Times New Roman"><span style="COLOR:#000099;FONT-SIZE:12pt">function questionnaire_form() </span></font></i></em><i><font color="#000099"><span style="FONT-STYLE:italic;COLOR:#000099"><br>
<em><i><font face="Times New Roman">{</font></i></em><br><em><i><font face="Times New Roman"> return drupal_get_form(&#39;questionnaire_my_form&#39;);</font></i></em><br><em><i><font face="Times New Roman">}</font></i></em></span></font></i><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><em><i><font color="#000099" size="3" face="Times New Roman"><span style="COLOR:#000099;FONT-SIZE:12pt">function questionnaire_my_form($form, &amp;$form_state) </span></font></i></em><i><font color="#000099"><span style="FONT-STYLE:italic;COLOR:#000099"><br>
<em><i><font face="Times New Roman">{  </font></i></em><br><em><i><font face="Times New Roman">  $form_state[&#39;cache&#39;] = TRUE;</font></i></em><br><em><i><font face="Times New Roman">  </font></i></em><br><em><i><font face="Times New Roman">  $all_categories = !empty($form_state[&#39;values&#39;][&#39;all_categories&#39;]) ? $form_state[&#39;values&#39;][&#39;all_categories&#39;] : 1;  </font></i></em></span></font></i><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><em><i><font color="#000099" size="3" face="Times New Roman"><span style="COLOR:#000099;FONT-SIZE:12pt">  $form[&#39;all_categories&#39;] = array(</span></font></i></em><i><font color="#000099"><span style="FONT-STYLE:italic;COLOR:#000099"><br>
<em><i><font face="Times New Roman">   &#39;#type&#39; =&gt; &#39;value&#39;, </font></i></em><br><em><i><font face="Times New Roman">   &#39;#default_value&#39; =&gt; $all_categories,</font></i></em><br><em><i><font face="Times New Roman">   &#39;#value&#39; =&gt; $all_categories);</font></i></em></span></font></i><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><em><i><font color="#000099" size="3" face="Times New Roman"><span style="COLOR:#000099;FONT-SIZE:12pt">   // The prefix/suffix provide the div that we&#39;re replacing, named by    </span></font></i></em><i><font color="#000099"><span style="FONT-STYLE:italic;COLOR:#000099"><br>
<em><i><font face="Times New Roman">   // #<u></u><u></u>ajax<u></u><u></u>[&#39;wrapper&#39;] above.    </font></i></em><br><em><i><font face="Times New Roman">   $form[&#39;category_fieldset&#39;] = array(    </font></i></em><br>
<em><i><font face="Times New Roman">        &#39;#title&#39; =&gt; t(&quot;Questions Categories&quot;),    </font></i></em><br><em><i><font face="Times New Roman">        &#39;#prefix&#39; =&gt; &#39;&lt;div id=&quot;category-div&quot;&gt;&#39;,    </font></i></em><br>
<em><i><font face="Times New Roman">        &#39;#suffix&#39; =&gt; &#39;&lt;/div&gt;&#39;,    </font></i></em><br><em><i><font face="Times New Roman">        &#39;#type&#39; =&gt; &#39;fieldset&#39;,    </font></i></em><br>
<em><i><font face="Times New Roman">        &#39;#description&#39; =&gt; t(&#39;Please enter the question categories&#39;), </font></i></em><br><em><i><font face="Times New Roman">   );</font></i></em></span></font></i><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"><br><em><i><font color="#000099" face="Times New Roman"><span style="COLOR:#000099">   for ($i=1; $i&lt;= $all_categories ; $i++) </span></font></i></em><i><font color="#000099"><span style="FONT-STYLE:italic;COLOR:#000099"><br>
<em><i><font face="Times New Roman">   {   </font></i></em><br><em><i><font face="Times New Roman">      $key = &#39;ctg&#39; . $i;</font></i></em><br><em><i><font face="Times New Roman">      $form[&#39;category_fieldset&#39;][&#39;category&#39;][$key] = array(      </font></i></em><br>
<em><i><font face="Times New Roman">         &#39;#type&#39; =&gt; &#39;textfield&#39;,      </font></i></em><br><em><i><font face="Times New Roman">         &#39;#title&#39; =&gt; &quot;Question category $i&quot;,    </font></i></em><br>
<em><i><font face="Times New Roman">         );  </font></i></em><br><em><i><font face="Times New Roman">    }  </font></i></em></span></font></i><u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><em><i><font color="#000099" size="3" face="Times New Roman"><span style="COLOR:#000099;FONT-SIZE:12pt">   $form[&#39;category_fieldset&#39;][&#39;add_more_category&#39;] = array(    </span></font></i></em><i><font color="#000099"><span style="FONT-STYLE:italic;COLOR:#000099"><br>
<em><i><font face="Times New Roman">        &#39;#type&#39; =&gt; &#39;submit&#39;,</font></i></em><br><em><i><font face="Times New Roman">        &#39;#value&#39; =&gt; t(&#39;Add More Categories&#39;),</font></i></em><br>
<em><i><font face="Times New Roman">        &#39;#<u></u><u></u>ajax<u></u><u></u>&#39; =&gt; array(      </font></i></em><br><em><i><font face="Times New Roman">          &#39;callback&#39; =&gt; &#39;questionnaire_category_callback&#39;,</font></i></em><br>
<em><i><font face="Times New Roman">          &#39;wrapper&#39; =&gt; &#39;category-div&#39;,      </font></i></em><br><em><i><font face="Times New Roman">          &#39;method&#39; =&gt; &#39;replace&#39;,      </font></i></em><br>
<em><i><font face="Times New Roman">          &#39;effect&#39; =&gt; &#39;fade&#39;,    </font></i></em><br><em><i><font face="Times New Roman">          ), </font></i></em><br><em><i><font face="Times New Roman">     );</font></i></em><br>
<em><i><font face="Times New Roman">    </font></i></em><br><em><i><font face="Times New Roman">    $form[&#39;submit&#39;] = array(    </font></i></em><br><em><i><font face="Times New Roman">        &#39;#type&#39; =&gt; &#39;submit&#39;,    </font></i></em><br>
<em><i><font face="Times New Roman">        &#39;#value&#39; =&gt; t(&#39;Submit&#39;),  </font></i></em><br><em><i><font face="Times New Roman">        );  </font></i></em><br><em><i><font face="Times New Roman">        </font></i></em><br>
<em><i><font face="Times New Roman">    return $form;</font></i></em><br><em><i><font face="Times New Roman">}   </font></i></em></span></font></i><u></u><u></u></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><em><i><font color="#000099" size="3" face="Times New Roman"><span style="COLOR:#000099;FONT-SIZE:12pt">function questionnaire_category_callback($form, &amp;$form_state) </span></font></i></em><i><font color="#000099"><span style="FONT-STYLE:italic;COLOR:#000099"><br>
<em><i><font face="Times New Roman">{ </font></i></em><br><em><i><font face="Times New Roman">  $form_state[&#39;values&#39;][&#39;all_categories&#39;] = $form_state[&#39;values&#39;][&#39;all_categories&#39;] + 1;</font></i></em><br>
<em><i><font face="Times New Roman">  return $form[&#39;category_fieldset&#39;];</font></i></em><br><em><i><font face="Times New Roman">}</font></i></em></span></font></i><u></u><u></u></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div>
<div>
<p class="MsoNormal"><em><i><font color="#000099" size="3" face="Times New Roman"><span style="COLOR:#000099;FONT-SIZE:12pt">?&gt;</span></font></i></em><u></u><u></u></p></div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="FONT-SIZE:12pt"> <u></u><u></u></span></font></p></div></div></div></div></div>Best Regards<br></blockquote>
<div>Kamal</div>
<div>NECS, Bangalore</div>
<div> </div>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">--<br>[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</blockquote></div><br>