title: Getting all child input elements within a div
body: <p>I am trying to get all the values of the input fields. The issue is all of the <code>&lt;input type=radio/&gt;</code> are dynamic and can increase or decrease at any time.</p>
  
  <p>So I am starting with the main DI and going from there. The problem I have now is I am not getting the input radio buttons values.</p>
  
  <p>So here are the steps I am intending to accomplish:</p>
  
  <ol>
  <li>If any radio button is selected, pass its value to the checkbox value, </li>
  <li>If the radio button is selected and the checkbox is not selected, do <em>not</em> pass to the checkbox value </li>
  </ol>
  
  <p>I am looking for a solution in JavaScript only - <strong>do not use jQuery</strong></p>
  
  <p>Here is my <a href="http://jsfiddle.net/4aeag76o/4/" rel="nofollow">jsFiddle code</a></p>
  
  <h3>HTML</h3>
  
  <pre><code>&lt;div style="display: block;" id="mymainDiv" class="fullFloat"&gt;
  
              &lt;input type="hidden" value="1" id="startIdxShMdeCarWisevId" name="startIdxShMdeCarWise"&gt;
                  &lt;div class="subTitle"&gt;UPS&lt;a class="fRight" onclick="localG('10',false,0,false,'UPS','1','$');" href="javascript:void(0);"&gt;Show Prices&lt;/a&gt;&lt;/div&gt;
                  &lt;div style="display:none;" id="Wheel_UPS"&gt;&lt;div class="loadingcheckout"&gt;&lt;/div&gt;&lt;/div&gt;
                      &lt;div id="Price_UPS"&gt;
  
                      &lt;/div&gt;
  
                  &lt;div class="wrapLeft wrapClear"&gt;
  
                              &lt;div class="wrapleft"&gt;
                                  &lt;label class=""&gt;
                                      &lt;input type="radio" value="11098" id="deliveryMethodId_1" name="deliveryMethodId" class="section" data-mask="" data-rev="" data-rel="false" data-carrier=""&gt; 
  
  
  
                                      &lt;span&gt;
                                          UPS Ground (Order by 9:30 PM EST)
                                      &lt;/span&gt;
                                      &lt;div class="wrapRight"&gt;
                                          &lt;div id="UPS_11098"&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/label&gt;
                              &lt;/div&gt;
  
                          &lt;input type="text" value="1" id="UPS"&gt;
  
                      &lt;/div&gt;
  
              &lt;input type="hidden" value="2" id="startIdxShMdeCarWisevId" name="startIdxShMdeCarWise"&gt;
                  &lt;div class="subTitle"&gt;Standard&lt;a class="fRight" onclick="localG('20',false,0,false,'Standard','2','$');" href="javascript:void(0);"&gt;Show Prices&lt;/a&gt;&lt;/div&gt;
                  &lt;div style="display:none;" id="Wheel_Standard"&gt;&lt;div class="loadingcheckout"&gt;&lt;/div&gt;&lt;/div&gt;
                      &lt;div id="Price_Standard"&gt;
  
                      &lt;/div&gt;
                  &lt;div class="wrapLeft wrapClear"&gt;
  
                              &lt;div class="wrapleft"&gt;
                                  &lt;label class=""&gt;
                                      &lt;input type="radio" value="11117" id="deliveryMethodId_2" name="deliveryMethodId" class="section" data-mask="" data-rev="" data-rel="false" data-carrier=""&gt; 
  
  
  
                                      &lt;span&gt;
                                          Standard Delivery - 2-3 Day Delivery at Ground Rate (Order by 9:30 PM EST) 
                                      &lt;/span&gt;
                                      &lt;div class="wrapRight"&gt;
                                          &lt;div id="Standard_11117"&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/label&gt;
                              &lt;/div&gt;
  
                          &lt;input type="text" value="1" id="Standard"&gt;
  
                      &lt;/div&gt;
  
              &lt;input type="hidden" value="3" id="startIdxShMdeCarWisevId" name="startIdxShMdeCarWise"&gt;
                  &lt;div class="subTitle"&gt;FedEx&lt;a class="fRight" onclick="localG('190',false,0,false,'FedEx','3','$');" href="javascript:void(0);"&gt;Show Prices&lt;/a&gt;&lt;/div&gt;
                  &lt;div style="display:none;" id="Wheel_FedEx"&gt;&lt;div class="loadingcheckout"&gt;&lt;/div&gt;&lt;/div&gt;
                      &lt;div id="Price_FedEx"&gt;
  
                      &lt;/div&gt;
                  &lt;div class="wrapLeft wrapClear"&gt;
  
                              &lt;div class="wrapleft"&gt;
                                  &lt;label class=""&gt;
                                      &lt;input type="radio" value="11088" id="deliveryMethodId_3" name="deliveryMethodId" class="section" data-mask="" data-rev="" data-rel="false" data-carrier=""&gt; 
  
  
  
                                      &lt;span&gt;
                                          FedEx Ground (Order by 8:00 PM EST)
                                      &lt;/span&gt;
                                      &lt;div class="wrapRight"&gt;
                                          &lt;div id="FedEx_11088"&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/label&gt;
                              &lt;/div&gt;
  
                          &lt;input type="text" value="1" id="FedEx"&gt;
  
                      &lt;/div&gt;
  
          &lt;/div&gt;
  &lt;input type="checkbox" name="shipmode" id="shipmode" value="" onclick="getpref('mymainDiv');"&gt;Get Value
  </code></pre>
  
  <h3>JS Code</h3>
  
  <p>This executes when the checkbox is clicked:</p>
  
  <pre><code>function getpref(val) {
      var wr = document.getElementById(val);
      childElements = wr.childNodes;
      //alert(childElements);
      for(var i = childElements.length-1; i&gt;=0; i--){
          var elem = childElements[i];
          console.log(elem.id);
          if(elem.id &amp;&amp; elem.id.indexOf(val+'_')==0){
              elem.style.display = 'block';
          }
      }
      //alert(val);
  }
  </code></pre>