2

I want to output this multi line html with variable into div from inside jquery but it never ouput the block of code inside div! I am using only variable inside it which is"itemName". could any one tell me why my code doesn't out to div ?

var siteContents2 ="<li> +
"       <iframe src='<iframe src='http://bsite.com/itemshow.php?"+itemName+"&title=ok&bgcolor=white' height=200 width=200 style='border: none;></iframe><br>+
"        <div class="details">+
"        <div class="title">+
"          <a href="/+itemName/">+itemName</a>+
"        </div>+
"        </div>+
"    </li> ";   

document.getElementById("myDiv").innerHTML += siteContents2;


</script>   
</head>

<body>

    <div id="myDiv"></div>
user1788736
  • 2,587
  • 18
  • 62
  • 107

4 Answers4

2

Your quotes and concats are not correct. try this:

var siteContents2 ="<li>" + 
 "       <iframe src='<iframe src='http://bsite.com/itemshow.php?"+itemName+"&title=ok&bgcolor=white' height=200 width=200 style='border: none;></iframe><br> "+
"        <div class='details'>"+
"        <div class='title'>"+
"          <a href='/"+itemName+"/'>"+itemName+"</a>"+
"        </div>"+
"        </div>"+
"    </li> ";  
krampstudio
  • 3,231
  • 2
  • 40
  • 56
  • Thanks . It worked well .could you tell me how i append these blocks of
  • so they get arranged in rows of 5 . Now they are printed one below each other! – user1788736 May 10 '13 at 09:33
  • i am trying to append the sitecontents2 to a div in body of page since am calling this script multiple time and want to arrange these outputs in rows of 5. Now each time i call the script it puts each iframe below each other. My goal is to have 5 iframe in a row! – user1788736 May 10 '13 at 09:51
  • so add your content in a sublist and add a new item to the parent list once the sublist size contains 5 items – krampstudio May 10 '13 at 10:05