clausowitz Posted October 21, 2011 Share Posted October 21, 2011 How can I call this from within php? <a href="#" onclick="return false" onmousedown="javascript:SlideBox('what10');"> this has to be within this: echo "....."; Quote Link to comment https://forums.phpfreaks.com/topic/249565-call-javaxcript-from-within-php/ Share on other sites More sharing options...
xtopolis Posted October 21, 2011 Share Posted October 21, 2011 <?php echo "<a href='#' onclick='return false' onmousedown=\"javascript:SlideBox('what10');\">"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/249565-call-javaxcript-from-within-php/#findComment-1281250 Share on other sites More sharing options...
clausowitz Posted October 22, 2011 Author Share Posted October 22, 2011 What about this? I can't get it right with the quotes: <?php if (isset($_SESSION['idx'])) { echo '<div class="containerheader" id="titleTextImg"><strong>Military Attachés accredited in Egypt</strong>'; echo '<a id="imageDivLink8" href="javascript:toggle5("contentDivImg8", "imageDivLink8");"><img src="images/x.gif" align="right"></a></div>'; echo '<div class="container" id="contentDivImg8" style="font-size:15px; display:block; margin-bottom:5px;"> <a href="member_countries.php"><img src="images/worldmap.gif" width="300" height="184" alt="Member Countries" title="Member Countries" border="0" /></a> <br /><span style="font-size:12px;">Click somewhere on the map to open the member countries page.</span></div><br />';} ?> Quote Link to comment https://forums.phpfreaks.com/topic/249565-call-javaxcript-from-within-php/#findComment-1281334 Share on other sites More sharing options...
xtopolis Posted October 22, 2011 Share Posted October 22, 2011 My personal preference, which I've found to be easier is to surround echo strings with double quotes, and then attributes within those strings with single quotes. Only when working with Javascript inside those strings will I use escaped double quotes (\") around the outside. <?php if (isset($_SESSION['idx'])) { echo "<div class='containerheader' id='titleTextImg'><strong>Military Attachés accredited in Egypt</strong>"; echo "<a id='imageDivLink8' href=\"javascript:toggle5('contentDivImg8', 'imageDivLink8');\"><img src='images/x.gif' align='right'></a></div>"; echo "<div class='container' id='contentDivImg8' style='font-size:15px; display:block; margin-bottom:5px;'> <a href='member_countries.php'><img src='images/worldmap.gif' width='300' height='184' alt='Member Countries' title='Member Countries' border='0' /></a> <br /><span style='font-size:12px;'>Click somewhere on the map to open the member countries page.</span></div><br />";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/249565-call-javaxcript-from-within-php/#findComment-1281391 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.