Cascading Values

Nested Arrays

by chayacooper

HTML

<input type="text" name="current_body_part_importance" />current_body_part_importance<br/>
<input type="text" name="current_body_part"  />current_body_part<br/>
<input type="text" name="current_body_part_description"  />current_body_part_description<br/>
<br/>

<div id="body_part_info" class="headerFont">          
           <label><input type="radio" name="body_shape_importance" class="show_value" checked="checked" value="PrimaryShape" />Primary Shape</label>
           <span style="padding-left:10px">
           <label><input type="radio" name="body_shape_importance" class="show_value" value="ToneCellulite" />Tone/Cellulite</label>
           </span>
           <span style="padding-left:10px">
           <label><input type="radio" name="body_shape_importance" value="SecondaryShape" /> Secondary Shape</label>
           </span>
</div><br/>


           <select name="body_part">
           <option value="bust" selected="selected">Bust</option>
           <option value="Hips">Hips</option> <!-- measurements_hips -->
           <option value="Waist">Waist</option><!-- measurements_waist -->
           <option value="stomach">Stomach</option>
           <option value="Height">Height</option> <!-- Measurements height_ft height_in -->
           <option value="Weight_description">Weight</option> <!-- Measurements - weight -->
           </select><br/>

               <label><input type="radio" name="body_part_description" value="Very_small" />Very Small</label>
               <label><input type="radio" name="body_part_description" value="Small" />Small</label>
               <label><input type="radio" name="body_part_description" value="Average" />Average</label>
               <label><input type="radio" name="body_part_description" value="Large" />Large</label>
               <label><input type="radio" name="body_part_description" value="Very_large" />Very Large</label>

JavaScript

$(function () {
    $('input[name="current_body_part_importance"]').val($("input[name=body_shape_importance]").val());
    $('input[name="current_body_part"]').val($("select[name=body_part]").val());
    $('input[name="current_body_part_description"]').val($("input[name=body_part_description]").val());
    
    $("[name=body_shape_importance]").change(function () {          $('input[name="current_body_part_importance"]').val($("input[name=body_shape_importance]:checked").val());
  
    });
    $("select[name=body_part]").change(function () {
        $('input[name="current_body_part"]').val($("select[name=body_part]").val());
    });        
    $("input[name=body_part_description]").change(function () {
        $('input[name="current_body_part_description"]').val($("input[name=body_part_description]:checked").val());
    });
});