My code is something like this:
function attr(el, attr, value)
{
el.setAttribute(attr, value);
}
var f2=document.createElement("form");
attr(f2, 'id', "det_"+tresult_no);
attr(f2, 'name', "form"+tresult_no);
var t2=document.createElement("TABLE");
attr(t2, 'width', 80);
attr(t2, 'border', 0);
f2.appendChild(t2);
then to see/confirm what I am doing is right, I do this:
document.getElementById('testing').value=t.innerHTML;
where “testing” is a textarea.
This works out pretty well… except with a lot of code, the textarea gets filled up and is abit hard to read.
Is there anyway to get some line breaks in the textarea after everytime I add one object to another?
Thanks!
Assuming the “testing” object is an input or textarea field that displays text and newlines, how about something like this?
or to just target a newline after closing tags:
Note, this isn’t a perfect regex for matching closing HTML tags, but for the purposes of debugging, it should work fine.