Jump to content

someone can help me to insert content to var ?


kfir91

Recommended Posts

function printdays() {
var content;
content =  "<tr>
for (i=1; i<=getDays(); i++) {
	<td class=\"daydate\"><a href=\"javascript:void(0);\" onClick=\"javascript:setDate(" + i + ");\">" + i + "</a></td>
	if (i%7 == 0)
		</tr><tr>
}
</tr>
document.getElementById('days').innerHTML = content;
}

how i insert all content to "var content" and print the var...

?

I'm assuming that the content you want to stick into the variable named 'content' is the HTML.  If so, you need to stick it in a string (read: inside of quotes) and concatenate it to what you already have using the '+' operator:

 

content += "<td class=\"daydate\"><a href=\"javascript:void(0);\" onClick=\"javascript:setDate(" + i + ");\">" + i + "</a></td>";

 

You'll need to do that for all of your dangling HTML.

Learn JavaScript.

function printdays() {
   var content =  "<tr>";
   for (i=1; i<=getDays(); i++) {
      content += "<td class=\"daydate\"><a href=\"javascript:void(0);\" onClick=\"javascript:setDate(" + i + ");\">" + i + "</a></td>";
      if (i%7 == 0)
         content += "</tr><tr>";
   }
   content += "</tr>";
   document.getElementById('days').innerHTML = content;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.