mediabob Posted July 11, 2007 Share Posted July 11, 2007 I am trying to make a pop up window that open when a person click a link, I use this same code on other pages but in this case the links are conditional based on the users member level so they are stored in a variable via a switch case statement. So my question is, how can I call the javascript pop up function INSIDE the php? normally I would use <a href="javascript:example('URL');">LINK</a> but since the link is inside a case statement and I had to use " on the outside I switched the inside to just ' and this resulted in the link cutting off at the first ' inside the bracket so when you hover over it you get javascript:example( as the URL if I remove the inside ' ' around the URL comepletely to make the code <a href='javascript:example(URL);'>LINK</a> the URL appears correctly when you hover the link but nothing happens when you click it. Any ideas? Thanks Link to comment https://forums.phpfreaks.com/topic/59413-solved-question-about-javascript-inside-php/ Share on other sites More sharing options...
OLG Posted July 11, 2007 Share Posted July 11, 2007 Will this not work ??? echo "<a href=\"javascript:example('URL');\">LINK[/url]"; You can also jump in and out of php (im not use to using case statements) <?php $variable = 1; if $variable ==1) { ?> <a href='javascript:example(URL);'>LINK[/url] <?php } else { ?> <a href='javascript:example(URLOne);'>LINK[/url] <?php } ?> Link to comment https://forums.phpfreaks.com/topic/59413-solved-question-about-javascript-inside-php/#findComment-295186 Share on other sites More sharing options...
Yesideez Posted July 11, 2007 Share Posted July 11, 2007 Can you show a little more of the code, like the entire switch statement? Please remember to post code between [code] and [/code] to make it more readable. Link to comment https://forums.phpfreaks.com/topic/59413-solved-question-about-javascript-inside-php/#findComment-295188 Share on other sites More sharing options...
Yesideez Posted July 11, 2007 Share Posted July 11, 2007 <?php switch ($level) { case 1:echo '<a href="javascript:example($URLone)">LINK</a>';break; case 2:echo '<a href="javascript:example($URLtwo)">LINK</a>';break; default:echo '<a href="javascript:example($URLthree)">LINK</a>';break; } ?> Something like that? Link to comment https://forums.phpfreaks.com/topic/59413-solved-question-about-javascript-inside-php/#findComment-295190 Share on other sites More sharing options...
mediabob Posted July 11, 2007 Author Share Posted July 11, 2007 bah I am being stupid (really tired) I forgot to use the \" inside, that fixed it Thanks! Link to comment https://forums.phpfreaks.com/topic/59413-solved-question-about-javascript-inside-php/#findComment-295195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.