jeger003 Posted January 24, 2009 Share Posted January 24, 2009 hello, I need some help on a javascript code that allows a link to open in a new window....but it doesnt work when i use it with php. here is my code: echo "<div align='left' class='FontColorsData'><span class='Public_Private_EmailFont'>Public Email:</span><a href='javascript:void(0)'onclick='window.open('Email_Request/form.html','linkname','height=400, width=450,scrollbars=no')'> Request an email NOW!</a></div>"; what am i missing? Quote Link to comment https://forums.phpfreaks.com/topic/142208-solved-javascript-and-php-allowed-at-once/ Share on other sites More sharing options...
.josh Posted January 24, 2009 Share Posted January 24, 2009 PHP parses its own code and sends the results to the client. javascript is not parsed by php. It is sent to the browser to be rendered. Your php is syntactically correct, so that stuff will be echoed. So...you're going to have to be more specific than "It doesn't work." Quote Link to comment https://forums.phpfreaks.com/topic/142208-solved-javascript-and-php-allowed-at-once/#findComment-744980 Share on other sites More sharing options...
jeger003 Posted January 24, 2009 Author Share Posted January 24, 2009 well.....when i click the link.....i dont get a pop up window of the form but i just figured out the problem....not sure how to fix it though this is what i am using //this one doesnt work in php because im forced to use single qouts '.....if i use double " i get error <div align='left' class='FontColorsData'><span class='Public_Private_EmailFont'>Public Email:</span><a href='javascript:void(0)'onclick='window.open('/Email_Request/form.html','linkname','height=400, width=450,scrollbars=no')'> Request an email NOW!</a></div> //this one works!! BUT....its because this one has double qouts ".....and i tested it in HTML...if i paste this in php i get error <div align='left' class='FontColorsData'><span class='Public_Private_EmailFont'>Public Email:</span><A HREF="javascript:void(0)"onclick="window.open('/Email_Request/form.html','linkname','height=400, width=450,scrollbars=no')"> Request an email NOW!</a></div> so basically it conflicts with the double quotes of the beginning echo "<...javascript....>"; Quote Link to comment https://forums.phpfreaks.com/topic/142208-solved-javascript-and-php-allowed-at-once/#findComment-744998 Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 you can escape double quotes with a backslash <?php echo "<div align='left' class='FontColorsData'><span class='Public_Private_EmailFont'>Public Email:</span><A HREF=\"javascript:void(0)\"onclick=\"window.open('http://www.clone003.site40.net/Email_Request/form.html','linkname','height=400, width=450,scrollbars=no')\"> Request an email NOW!</a></div>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/142208-solved-javascript-and-php-allowed-at-once/#findComment-745000 Share on other sites More sharing options...
jeger003 Posted January 24, 2009 Author Share Posted January 24, 2009 LOL AWESOME JOB! i never knew that was possible...... THANKS FOR YOUR HELP GUYS!!! it required just two more backslashes and it works great.....if anyone needs it in the future its below. echo "<div align='left' class='FontColorsData'><span class='Public_Private_EmailFont'>Public Email:</span><A HREF=\"javascript:void(0)\" onclick=\"window.open('/Email_Request/form.html','linkname','height=400, width=450,scrollbars=no')\"> Request an email NOW!</a></div>"; Quote Link to comment https://forums.phpfreaks.com/topic/142208-solved-javascript-and-php-allowed-at-once/#findComment-745010 Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 Glad to be of help :-) Quote Link to comment https://forums.phpfreaks.com/topic/142208-solved-javascript-and-php-allowed-at-once/#findComment-745020 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.