Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-- function to enable editing of content if disabled for new records --\
- function edit(e,elems)
- {
- if ( e.value == "new" )
- {
- $(e).parent().parent().find(":input[readonly]").each(function(index) {
- $(this).prop('readonly',false);
- $(this).addClass('highlight');
- });
- $(e).parent().parent().find("select[disabled]").each(function(index) {
- $(this).prop('disabled',false);
- $(this).addClass('highlight');
- //-- Insert dynamic options --\
- if ($(this).attr('name') == 'low')
- {
- var optVal = "option[value='" + $(this).val() + "']";
- var optclone = $("#affoptions").clone();
- $(optclone).find(optVal).attr("selected",true);
- $(this).html($(optclone).find("option"));
- }
- if ($(this).attr('name') == 'high')
- {
- var optVal = "option[value='" + $(this).val() + "']";
- optclone = $("#insoptions").clone();
- $(optclone).find(optVal).attr("selected",true);
- $(this).html($(optclone).find("option"));
- }
- });
- $(e).parent().parent().find(elems).focus();
- } else {
- $(e).parent().parent().find(elems).each(function(index) {
- if ( $(this).is('select') )
- {
- $(this).prop('disabled',true);
- } else {
- $(this).prop('readonly',true);
- }
- $(this).removeClass('highlight');
- });
- }
- }
- <div id="affoptions" class="options">
- <option value="0001">0001 | A</option>
- <option value="0002">0002 | B</option>
- <option value="*">* | All</option>
- <option value="0003">0003 | C</option>
- <option value="0004">0004 | D</option>
- </div>
- <div id="affoptions" class="options">
- <select>
- <option value="0001">0001 | A</option>
- <option value="0002">0002 | B</option>
- <option value="*">* | All</option>
- <option value="0003">0003 | C</option>
- <option value="0004">0004 | D</option>
- </select>
- </div>
Add Comment
Please, Sign In to add comment