ajaxiskey Posted August 12, 2010 Share Posted August 12, 2010 How can I make this string work? document.getElementById("PAGE").innerHTML = '<div style="color: #FE4D1B; text-align: center; font-family: Arial; font-size: 12px; background-color: #222222;">View Comments</div><div id="VCP_COMMENTS" style="height: 166px; overflow: auto; border: 1px dotted #444444; width: 444px; margin: auto; margin-top: 4px;"></div><div id="VCP_BOX" style="text-align: center;"><textarea id="VCP_CONTENT" style="background-color: #000000; color: #FFFFFF; border: 1px dotted #FE4D1B; width: 444px; font-size: 10px; height: 30px; font-family: Arial; margin: auto; margin-top: 4px;"></textarea><input type="button" value="Post Comment" onClick="POST_NEWS_COMMENT('+NEWS_ID+',document.getElementById("VCP_CONTENT").value);" style="margin-top: 2px; background-color: #000000; color: #FFFFFF; border: 1px dotted #FE4D1B; width: 446px; font-family: Arial;"></div>'; Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted August 12, 2010 Share Posted August 12, 2010 Create the string before hand, and do it over multiple lines, so it's easier to read: var string = '<div style="color: #FE4D1B; text-align: center; font-family: Arial; font-size: 12px; background-color: #222222;">View Comments</div>'; string += '<div id="VCP_COMMENTS" style="height: 166px; overflow: auto; border: 1px dotted #444444; width: 444px; margin: auto; margin-top: 4px;"></div>'; string += '<div id="VCP_BOX" style="text-align: center;"><textarea id="VCP_CONTENT" style="background-color: #000000; color: #FFFFFF; border: 1px dotted #FE4D1B; width: 444px; font-size: 10px; height: 30px; font-family: Arial; margin: auto; margin-top: 4px;"></textarea>'; string += '<input type="button" value="Post Comment" onClick="javascript: POST_NEWS_COMMENT(' + NEWS_ID + ',\'' + document.getElementById("VCP_CONTENT").value + '\');" style="margin-top: 2px; background-color: #000000; color: #FFFFFF; border: 1px dotted #FE4D1B; width: 446px; font-family: Arial;"></div>'; document.getElementById("PAGE").innerHTML = string; I fixed a few things up where you broke out of the string for the JavaScript variable and for where you got the value of a field. I also surrounded that with escaped single quotes. Quote Link to comment Share on other sites More sharing options...
ajaxiskey Posted August 12, 2010 Author Share Posted August 12, 2010 document.getElementById("VCP_CONTENT").value Is suppose to be displayed like that, I don't want it's value to be inserted there. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted August 12, 2010 Share Posted August 12, 2010 Why are you doing that? 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.