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>'; Link to comment https://forums.phpfreaks.com/topic/210505-string-problem/ 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. Link to comment https://forums.phpfreaks.com/topic/210505-string-problem/#findComment-1098352 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. Link to comment https://forums.phpfreaks.com/topic/210505-string-problem/#findComment-1098354 Share on other sites More sharing options...
JasonLewis Posted August 12, 2010 Share Posted August 12, 2010 Why are you doing that? Link to comment https://forums.phpfreaks.com/topic/210505-string-problem/#findComment-1098357 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.