twatkins Posted July 20, 2007 Share Posted July 20, 2007 im trying to embed the java into php here is my script <? $test = 005; print "<SCRIPT LANGUAGE=\"javascript\"><!--\n"; print "function new_window()\n" print " {\n"; print " OpenWindow=window.open(\"../test/test_image.php?pump=".$test."\", \"newwin\", \"height=300, width=400,toolbar=no,scrollbars=\"+scroll+\",menubar=no\");\n"; print " } \n"; print "//--></SCRIPT>\n"; ?> for some reason i cant figure out why when i pull the page up im my browser i get \n"; ?> so i guess im not ending it right Quote Link to comment https://forums.phpfreaks.com/topic/60965-solved-embeding-javascript/ Share on other sites More sharing options...
phat_hip_prog Posted July 20, 2007 Share Posted July 20, 2007 Not sure cos I ain't checked it, but these ('<!--' & '-->') might be commenting out your code, have a look at the source from your browser...? Quote Link to comment https://forums.phpfreaks.com/topic/60965-solved-embeding-javascript/#findComment-303366 Share on other sites More sharing options...
MadTechie Posted July 20, 2007 Share Posted July 20, 2007 <? $test = 005; print "<SCRIPT LANGUAGE=\"javascript\"><!--\n"; print "function new_window()\n"; //<---missed the ; print " {\n"; print " OpenWindow=window.open(\"../test/test_image.php?pump=".$test."\", \"newwin\", \"height=300, width=400,toolbar=no,scrollbars=\"+scroll+\",menubar=no\");\n"; print " } \n"; print "//--></SCRIPT>\n"; ?> option #2 <?php $test = 005; ?> <SCRIPT LANGUAGE="javascript"> <!-- function new_window() OpenWindow=window.open("../test/test_image.php?pump=<?php echo $test ?>", "newwin", "height=300, width=400,toolbar=no,scrollbars=scroll,menubar=no"); } //--> </SCRIPT> Quote Link to comment https://forums.phpfreaks.com/topic/60965-solved-embeding-javascript/#findComment-303371 Share on other sites More sharing options...
twatkins Posted July 20, 2007 Author Share Posted July 20, 2007 thanks for the replies but option one i still get the same and 2 I the following address instead of http://localhost//test/test_image.php?pump=%3C?php%20echo%20$test;%20?%3E http://localhost//test/test_image.php?pump=005 Quote Link to comment https://forums.phpfreaks.com/topic/60965-solved-embeding-javascript/#findComment-303389 Share on other sites More sharing options...
MadTechie Posted July 20, 2007 Share Posted July 20, 2007 i tested the code i sent.. it works fine.. the problem is in something not posted Quote Link to comment https://forums.phpfreaks.com/topic/60965-solved-embeding-javascript/#findComment-303457 Share on other sites More sharing options...
twatkins Posted July 20, 2007 Author Share Posted July 20, 2007 I'm sorry you were right im stupid Quote Link to comment https://forums.phpfreaks.com/topic/60965-solved-embeding-javascript/#findComment-303468 Share on other sites More sharing options...
MadTechie Posted July 20, 2007 Share Posted July 20, 2007 happens to us all not ad bad as when i tested a script on one site while uploading it to another.. Quote Link to comment https://forums.phpfreaks.com/topic/60965-solved-embeding-javascript/#findComment-303470 Share on other sites More sharing options...
KevinM1 Posted July 20, 2007 Share Posted July 20, 2007 Unless you want to ensure that old (I'm talking ~1999 era) browsers either use or ignore your JavaScript, there's no reason to embed it in HTML comments. All modern browsers understand JavaScript. As far as your problem, MadTechie did fix it. I recommend using single-quoted strings in PHP. I've read that they're processed faster, since they don't interpolate embedded variables, and you don't need to escape double-quotes, either, which improves readability. Finally, and this is a matter of personal preference, I suggest moving all of your JavaScript to external files. It saves on clutter in the markup, and makes updating those scripts easier as they're in a centralized location. Quote Link to comment https://forums.phpfreaks.com/topic/60965-solved-embeding-javascript/#findComment-303471 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.