You need to echo "each line of the script and or escape \"quotes\" "; if you post the script some will give you an example
Hi, I dont think, its a complex one. You can use the echo function for this. You can simply write the code like below echo '<script langauage="javascript">'; echo 'alert("Testing"); echo '</script>'; If you not mean the above problem, keep post in this forum. We will try to help you. Soman
Here's the code I'd need to insert into a PHP page. It's from Google's Friend Connect. <!-- Include the Google Friend Connect javascript library. --> <script type="text/javascript" src="http://www.google.com/friendconnect/script/friendconnect.js"></script> <!-- Define the div tag where the gadget will be inserted. --> <div id="div-xxxxxx" style="width:276px;border:1px solid #cccccc;"></div> <!-- Render the gadget into a div. --> <script type="text/javascript"> var skin = {}; skin['BORDER_COLOR'] = '#cccccc'; skin['ENDCAP_BG_COLOR'] = '#e0ecff'; skin['ENDCAP_TEXT_COLOR'] = '#333333'; skin['ENDCAP_LINK_COLOR'] = '#0000cc'; skin['ALTERNATE_BG_COLOR'] = '#ccffff'; skin['CONTENT_BG_COLOR'] = '#ffccff'; skin['CONTENT_LINK_COLOR'] = '#0000cc'; skin['CONTENT_TEXT_COLOR'] = '#333333'; skin['CONTENT_SECONDARY_LINK_COLOR'] = '#7777cc'; skin['CONTENT_SECONDARY_TEXT_COLOR'] = '#666666'; skin['CONTENT_HEADLINE_COLOR'] = '#333333'; skin['NUMBER_ROWS'] = '4'; google.friendconnect.container.setParentUrl('/' /* location of rpc_relay.html and canvas.html */); google.friendconnect.container.renderMembersGadget( { id: 'xxxxxx', site: 'xxxxxx' }, skin); </script>
Try this, remembering to change the <div id= echo "<div id='div-xxxxxx' style='width:276px;border:1px solid #cccccc;'></div>"; echo "<script type='text/javascript'>"; echo "var skin = {};"; echo "skin['BORDER_COLOR'] = '#cccccc';"; echo "skin['ENDCAP_BG_COLOR'] = '#e0ecff';"; echo "skin['ENDCAP_TEXT_COLOR'] = '#333333';"; echo "skin['ENDCAP_LINK_COLOR'] = '#0000cc';"; echo "skin['ALTERNATE_BG_COLOR'] = '#ccffff';"; echo "skin['CONTENT_BG_COLOR'] = '#ffccff';"; echo "skin['CONTENT_LINK_COLOR'] = '#0000cc';"; echo "skin['CONTENT_TEXT_COLOR'] = '#333333';"; echo "skin['CONTENT_SECONDARY_LINK_COLOR'] = '#7777cc';"; echo "skin['CONTENT_SECONDARY_TEXT_COLOR'] = '#666666';"; echo "skin['CONTENT_HEADLINE_COLOR'] = '#333333';"; echo "skin['NUMBER_ROWS'] = '4';"; echo "google.friendconnect.container.setParentUrl('/' /* location of rpc_relay.html and canvas.html */);"; echo "google.friendconnect.container.renderMembersGadget("; echo "{ id: 'xxxxxx',"; echo "site: 'xxxxxx' },"; echo "skin);"; echo "</script>"; PHP:
for you it will be <?php echo <<<_HTML_ <script type="text/javascript" src="http://www.google.com/friendconnect/script/friendconnect.js"></script> <!-- Define the div tag where the gadget will be inserted. --> <div id="div-xxxxxx" style="width:276px;border:1px solid #cccccc;"></div> <!-- Render the gadget into a div. --> <script type="text/javascript"> var skin = {}; skin['BORDER_COLOR'] = '#cccccc'; skin['ENDCAP_BG_COLOR'] = '#e0ecff'; skin['ENDCAP_TEXT_COLOR'] = '#333333'; skin['ENDCAP_LINK_COLOR'] = '#0000cc'; skin['ALTERNATE_BG_COLOR'] = '#ccffff'; skin['CONTENT_BG_COLOR'] = '#ffccff'; skin['CONTENT_LINK_COLOR'] = '#0000cc'; skin['CONTENT_TEXT_COLOR'] = '#333333'; skin['CONTENT_SECONDARY_LINK_COLOR'] = '#7777cc'; skin['CONTENT_SECONDARY_TEXT_COLOR'] = '#666666'; skin['CONTENT_HEADLINE_COLOR'] = '#333333'; skin['NUMBER_ROWS'] = '4'; google.friendconnect.container.setParentUrl('/' /* location of rpc_relay.html and canvas.html */); google.friendconnect.container.renderMembersGadget( { id: 'xxxxxx', site: 'xxxxxx' }, skin); </script> _HTML_; PHP CODE HERE ?> It must work
Hi, Simple concept if you use echo ' you have to replace ' into \' in the javascript code. if you use echo " you have to replace all " into \" in the javascript code. Soman
I suggest you use include 'javascript.html'; just one line. put the javascript in one file with script tags. That way if you site needs fixing you can just worry about one thing at a time.
Hi you can insert javascript in PHP by using the following code echo '<script langauage="javascript">'; echo 'alert("Testing"); echo '</script>';