html - jquery dropdown onclick select nearest radio -


i have list of items can have values selected dropdown or entered free text. i'd have radio button automatically selected beside either dropdown or text box when they're clicked on.

i have:

<script type="text/javascript">   $(".click_radio").click(function() {       $(this).find('input[type=radio]').prop('checked', true);   }); </script>  <html>   <table>     <tr>       <td><input type="checkbox" name="ord_55" value="yes" /> sodium chloride </td>       <td><input type="radio" name="dose" value="drop"/> &nbsp;         <select id="drop_dose_1" name="nsbolus_drop_dose" class="click_radio">           <option></option>           <option>250</option>           <option>500</option>           <option>1000</option>         </select> ml       </td>       <td><input type="radio" name="dose" value="text"/> &nbsp;          <input type="text" size="4" id="text_dose_1" name="nsbolus_text_dose" value="" class="click_radio"/> ml       </td>       <td><select name="nsbolus_pri">           <option>stat</option>           <option>next sch</option>           <option>1st dose today</option>         </select></td>     </tr>   </table> </html> 

i trigger directly want universal script work of dozens of similar items follow one.

thanks!

edit should mention i'm on jquery 1.9.1

try this:

$('.click_radio').on('click change', function(){     $(this).prev('input[type="radio"]').prop('checked', true); }); 

this uses .prev() , work many elements need long radio input immediately before element .click_radio class.

here working: http://jsfiddle.net/tv8sr/4/


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -