I have two functions, one that creates a table like so:
function return_formatted_results(result_no,addy,title,own_comment)
{
var div=document.createElement("DIV");
attr(div, 'id', 'div_id'+result_no);
var form=document.createElement("FORM");
attr(form, 'id', 'det_'+result_no);
attr(form, 'name', 'form'+result_no);
attr(form, 'method', 'post');
attr(form, 'action', '');
// ###############
// add all other objects and attributes here
// ###################
form.appendChild(table);
div.appendChild(form);
}
and then I have this function that calls the above function:
function get_urls_and_display()
{
var allTables=new Array();
for(var i=0;i<url.length;i++)
{ allTables[i]=return_formatted_results(i,url[i],the_title[i],the_comm[i]); }
document.getElementById("wait").appendChild(allTables.join("\n\n"));
The problem is the join() in the last line throws an error. I am new to working with the whole DOM thing like I did above, so have no idea what to use instead. I used to use plain html before and join() worked then.
Thanks!
You’ve got a few problems:
return_formatted_resultsdoesn’t actually return anything (ironic because it’s explicitly stated in the name)joinis indeed only for strings.After you make
return_formatted_resultsreturndiv, try this forget_urls_and_display:Additionally, it looks like you have three different arrays all containing related data. A more suitable data structure would be a list of objects. You could define that like this:
Here’s what
get_urls_and_displaywould look like with that: