Javascript format html?

Hi folks im very new to js ok so I am trying to foreach this code but can’t make it happen:

for (var key in OnLoadArraySliced) {

OnLoadHtml += "<div id=\""+OnLoadArraySliced[key].UserId+"\">"+




"<div class=\"ow_user_list_picture\">
  
<div class=\"ow_avatar\">
<a href=\""+ OnLoadArraySliced[key].ProfileUrl + "\">
<img src=\""+ OnLoadArraySliced[key].AvatarUrl + "\">
</a>
</div>
</div>

<div class=\"ow_user_list_data\">
+ OnLoadArraySliced[key].UserName + 
        
<div class=\"ow_small\">
"desc"
</div>
</div>"+








 "</div>";

}

You don’t close the quotes around your function here:

<div class=\"ow_user_list_data\">
+ OnLoadArraySliced[key].UserName + 
        
<div class=\"ow_small\">

Otherwise, what happens that should not, or vice versa?

Thanks so much im only starting with js. Appreciate this.

Embedded quotes are always a pain - I try everything I can to not have to escape stuff inside strings - in your position I’d have used single-quotes:

OnLoadHtml += "<div id='"+OnLoadArraySliced[key].UserId+"'>"+

and so on.

Listen… You should to do something with your whole concept. To build HTML by JS so is absolutely nonsense.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.