Skip to content

Instantly share code, notes, and snippets.

@AbdulRafay
Last active January 28, 2020 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbdulRafay/6aad434d96574c3e6d2f52e9704ccb83 to your computer and use it in GitHub Desktop.
Save AbdulRafay/6aad434d96574c3e6d2f52e9704ccb83 to your computer and use it in GitHub Desktop.
gather table cell values in last cell's form hidden field
jQuery('tr', jQuery(".ht-table").first().find('tbody')).each(function(i,j){
var last=jQuery(j).children().last().get(0);
var form=jQuery(last).find("form");
let l=jQuery("th,td",j);
var temp="<h3>"+jQuery(j).closest("div.single_toggle").find('p.toggler').text()+"</h3>";
jQuery(l).each((a,b)=>{
if(jQuery(b).children().length == 0){
temp += "<p>"+jQuery(j).closest("table").find("thead>tr>th:eq("+a+")").text()+": "+jQuery(b).text()+"</p></br>";
}
});
jQuery('<input>').attr({
type: 'hidden',
name: "postDescriptionHTML",//jQuery(j).closest("table").find("thead>tr>th:eq("+a+")").text(),
value:"<span>"+temp+"</span>"
}).appendTo(form);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment