kfir91 Posted June 19, 2009 Share Posted June 19, 2009 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... ? Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted June 19, 2009 Share Posted June 19, 2009 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. Quote Link to comment Share on other sites More sharing options...
kfir91 Posted June 19, 2009 Author Share Posted June 19, 2009 i want the the function print the for too ... on the page Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 20, 2009 Share Posted June 20, 2009 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; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.