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...

?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.