How to clear form values on slideup in jquery?
<p>I have a simple form for a hotel accommodation tool. User selects the number of adults and children from dropdown boxes and the form then lets the user select the ages of children from newly generated dropdown boxes.</p>

<p>I can show and hide the select boxes. However, once a select box is shown, its value is posted no matter if it's later hidden or not. I need to clear or reset the values of select boxes which are no longer displayed.</p>

<p>Here is my jquery:</p>

<pre><code>    $(document).ready(function(){
$("#selectchild").change(function(){

    switch ($(this).val())
    {
      case "0":
        $("#hidechild1").slideUp("fast");
        $("#hidechild2").slideUp("fast");
        break;  
      case "1":
        $("#hidechild1").slideDown("fast");
        $("#hidechild2").slideUp("fast");
        break;
      case "2":
        $("#hidechild1").slideDown("fast");
        $("#hidechild2").slideDown("fast");
        break;
}           
    });
});
</code></pre>

<p>And here is my HTML:</p>

<pre><code>&lt;form id="ExampleForm" method="post" action="results.php"&gt;
&lt;fieldset&gt;
    &lt;legend&gt;Accommodation details. Please choose number of adults and children&lt;/legend&gt;     
    &lt;div class="input select"&gt;
        &lt;label for="selectadult"&gt;Adult (&gt;12)&lt;/label&gt;
        &lt;select name="selectadult" id="selectadult"&gt;
            &lt;option value="1"&gt;1&lt;/option&gt;
            &lt;option value="2"&gt;2&lt;/option&gt;
            &lt;option value="3"&gt;3&lt;/option&gt;                            
        &lt;/select&gt;
    &lt;/div&gt;

    &lt;div class="input select"&gt;
        &lt;label for="selectchild"&gt;Children (0-12)&lt;/label&gt;
        &lt;select name="selectchild" id="selectchild"&gt;
            &lt;option value="0"&gt;0&lt;/option&gt;
            &lt;option value="1"&gt;1&lt;/option&gt;
            &lt;option value="2"&gt;2&lt;/option&gt;                    
        &lt;/select&gt;
    &lt;/div&gt;      

    &lt;div class="hide" id="hidechild1"&gt;
        &lt;br/&gt;Please specify the ages of children:
        &lt;div class="input select"&gt;
            &lt;label for="selectchild1"&gt;Child 1:&lt;/label&gt;
            &lt;select name="selectchild1" id="selectchild1"&gt;
            &lt;option value="none"&gt;-?-&lt;/option&gt;
            &lt;option value="&lt;1"&gt;&lt;1&lt;/option&gt;
            &lt;? for ($i=1;$i&lt;=12;$i++) { echo "&lt;option value=\"$i\"&gt;$i&lt;/option&gt;"; } ?&gt;
            &lt;/select&gt;
        &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="hide" id="hidechild2"&gt;
        &lt;div class="input select"&gt;
            &lt;label for="selectchild2"&gt;Child 2:&lt;/label&gt;
            &lt;select name="selectchild2" id="selectchild2"&gt;
            &lt;option value="none"&gt;-?-&lt;/option&gt;
            &lt;option value="&lt;1"&gt;&lt;1&lt;/option&gt;              
            &lt;? for ($i=1;$i&lt;=12;$i++) { echo "&lt;option value=\"$i\"&gt;$i&lt;/option&gt;"; } ?&gt;
            &lt;/select&gt;
        &lt;/div&gt;
    &lt;/div&gt;      

&lt;/fieldset&gt;
&lt;div class="submit"&gt;
    &lt;input type="submit" value="Submit!" /&gt;
&lt;/div&gt;
&lt;/form&gt;
</code></pre>
