code_junkie

jQuery multiple radio buttons

Nov 11th, 2011
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <tr>
  2. <td align="left" style="width: 300px">
  3. <div id="div_s_0">
  4. <input type="radio" name="s_0" value="1" />Public
  5. <input type="radio" name="s_0" value="2" />Not Public
  6. <input type="radio" name="s_0" value="3" />Confidential
  7. </div>
  8. </td>
  9. </tr>
  10. <tr>
  11. <td align="left" style="width: 300px">
  12. <div id="div_s_1">
  13. <input type="radio" name="s_1" value="1" />Public
  14. <input type="radio" name="s_1" value="2" />Not Public
  15. <input type="radio" name="s_1" value="3" />Confidential
  16. </div>
  17. </td>
  18. </tr>
  19.  
  20. $(document).ready(function() {
  21. $("input:radio").click(function() {
  22. var index = parseInt(this.name.split('_')[1])
  23. });
  24. });
  25.  
  26. $($("table").children()[0]).children().length
  27.  
  28. var rowIndex = $("#mytable tr").index($(this).parents("tr"));
  29. var inputName = $(this).attr("name");
  30. alert("Input Name: " + inputName + "; RowIndex: " + rowIndex);
  31.  
  32. $("#div_s_0 input[type='radio']").onclick = function() {
  33. if ($("#div_s_0 input[type='radio']:last").attr('checked') == 'checked') {
  34. /* add a new element */
  35. }
  36. }
Add Comment
Please, Sign In to add comment