Guest User

Untitled

a guest
Jan 18th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. //-- function to enable editing of content if disabled for new records --\
  2. function edit(e,elems)
  3. {
  4. if ( e.value == "new" )
  5. {
  6. $(e).parent().parent().find(":input[readonly]").each(function(index) {
  7. $(this).prop('readonly',false);
  8. $(this).addClass('highlight');
  9. });
  10. $(e).parent().parent().find("select[disabled]").each(function(index) {
  11. $(this).prop('disabled',false);
  12. $(this).addClass('highlight');
  13. //-- Insert dynamic options --\
  14. if ($(this).attr('name') == 'low')
  15. {
  16. var optVal = "option[value='" + $(this).val() + "']";
  17. var optclone = $("#affoptions").clone();
  18. $(optclone).find(optVal).attr("selected",true);
  19. $(this).html($(optclone).find("option"));
  20. }
  21. if ($(this).attr('name') == 'high')
  22. {
  23. var optVal = "option[value='" + $(this).val() + "']";
  24. optclone = $("#insoptions").clone();
  25. $(optclone).find(optVal).attr("selected",true);
  26. $(this).html($(optclone).find("option"));
  27. }
  28. });
  29. $(e).parent().parent().find(elems).focus();
  30. } else {
  31. $(e).parent().parent().find(elems).each(function(index) {
  32. if ( $(this).is('select') )
  33. {
  34. $(this).prop('disabled',true);
  35. } else {
  36. $(this).prop('readonly',true);
  37. }
  38. $(this).removeClass('highlight');
  39. });
  40. }
  41. }
  42.  
  43. <div id="affoptions" class="options">
  44. <option value="0001">0001 | A</option>
  45. <option value="0002">0002 | B</option>
  46. <option value="*">* | All</option>
  47. <option value="0003">0003 | C</option>
  48. <option value="0004">0004 | D</option>
  49. </div>
  50.  
  51. <div id="affoptions" class="options">
  52. <select>
  53. <option value="0001">0001 | A</option>
  54. <option value="0002">0002 | B</option>
  55. <option value="*">* | All</option>
  56. <option value="0003">0003 | C</option>
  57. <option value="0004">0004 | D</option>
  58. </select>
  59. </div>
Add Comment
Please, Sign In to add comment