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... ? Link to comment https://forums.phpfreaks.com/topic/162958-someone-can-help-me-to-insert-content-to-var/ 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. Link to comment https://forums.phpfreaks.com/topic/162958-someone-can-help-me-to-insert-content-to-var/#findComment-859853 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 Link to comment https://forums.phpfreaks.com/topic/162958-someone-can-help-me-to-insert-content-to-var/#findComment-859859 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; } Link to comment https://forums.phpfreaks.com/topic/162958-someone-can-help-me-to-insert-content-to-var/#findComment-860038 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.