Jump to content

Clear fields in the bulk edit screen


Recommended Posts

Hi there,

 

I would like to share a JS solution which I have used for my project.

This script that can be used to clear fields in the bulk edit screen. The bulk edit screen typically displays the data from the last update, and my JS allows not show the previous content of fields.

Place following JS into the Footer of Bulk edit screen. Make sure that you have disabled HTML editor.

<script type="text/javascript">

var aaa= document.getElementById("BulkUpdateFormBody");
var v_li = aaa.getElementsByTagName("input");
var v_ls = aaa.getElementsByTagName("select");
var v_lt = aaa.getElementsByTagName("textarea");

 var f_tmpf = function(v_list, v_resList){
 var v_res = v_resList || []; 
 var v_length = v_list.length;
 for(var v_i = 0; v_i < v_length; v_i++) 
  if((v_list[v_i].type || "").toUpperCase()!="HIDDEN" && (v_list[v_i].nodeName||'').search(/input|select|textarea/ig) != -1)
   v_res.push(v_list[v_i]); 
   v_resList = v_res;
 return v_res;
}

var v_cleanI=f_tmpf(v_lt, f_tmpf(v_ls, f_tmpf(v_li, [])));

v_cleanI.forEach(function(v_i){ v_i.value = ""; });

</script>

I hope this will be useful for someone. 

 

Link to comment
Share on other sites

Thank you for posting this helpful JS solution!  This is exactly what I am needing for one of our projects.  The only problem I'm experiencing is that my bulk edit data is not saving to my table after adding this script to the DataPage.  Any ideas what I might be doing wrong?  I used the script as is - no changes.

Link to comment
Share on other sites

Hi Rmorr,

Thank you for your feedback.

I`ve applied few changes to my initial solution which should resolve the issue.

<script type="text/javascript">
var aaa= document.getElementById("BulkUpdateFormBody");
var v_li = aaa.getElementsByTagName("input");
var v_ls = aaa.getElementsByTagName("select");
var v_lt = aaa.getElementsByTagName("textarea");

var f_tmpf = function(v_list, v_resList){
 var v_res = v_resList || []; 
 var v_length = v_list.length;
 for(var v_i = 0; v_i < v_length; v_i++) 
  if((v_list[v_i].type || "").search(/HIDDEN|button|image/ig)==-1 && (v_list[v_i].nodeName||'').search(/input|select|textarea/ig) != -1)
   v_res.push(v_list[v_i]); 

 return v_res;
}

var v_cleanI=f_tmpf(v_lt, f_tmpf(v_ls, f_tmpf(v_li, [])));

v_cleanI.forEach(function(v_i){ v_i.type == "checkbox" ? v_i.checked = false : v_i.value = ""; });

</script>

Hope this helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...