fraser5002 Posted July 4, 2011 Share Posted July 4, 2011 Hi this is probably a easy question but i have been rattling my mind to it for about half an hour now . Im using an onclick event of a button to open a new webpage passing a PHP variable through the url at the moment im trying to use the following code. onclick="window.open('otherwebpage.php?itemtopassinurl=<? echo "$title[$i]"; ?>','popuppage','width=300,toolbar=1,resizable=0,scrollbars=yes,height=700,top=100,left=100')" ?>' I know i cant use the " " in the php bit of the code but i dont know what to use instead . I assume i cant use the ' character either??? How can i do this? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/241083-passing-php-variable-through-url/ Share on other sites More sharing options...
rascle Posted July 4, 2011 Share Posted July 4, 2011 Have you tried that code? You should be able to use "" because PHP is a server side script and so the information is parsed before the Javascript is meaning the "" dont affect the javascript could. Hope this helps Rhys Quote Link to comment https://forums.phpfreaks.com/topic/241083-passing-php-variable-through-url/#findComment-1238344 Share on other sites More sharing options...
Pikachu2000 Posted July 4, 2011 Share Posted July 4, 2011 You shouldn't need the quotes at all. <?php echo $title[$i]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/241083-passing-php-variable-through-url/#findComment-1238350 Share on other sites More sharing options...
monkeytooth Posted July 4, 2011 Share Posted July 4, 2011 Original: onclick="window.open('otherwebpage.php?itemtopassinurl=<? echo "$title[$i]"; ?>','popuppage','width=300,toolbar=1,resizable=0,scrollbars=yes,height=700,top=100,left=100')" ?>' Revised: onclick="window.open('otherwebpage.php?itemtopassinurl=<?php echo $title[$i]; ?>','popuppage','width=300,toolbar=1,resizable=0,scrollbars=yes,height=700,top=100,left=100')" its worth noting that use of <? the shortcode version shouldn't be used in general as its a depreciated method that I believe come PHP v6 will be removed all together. Quote Link to comment https://forums.phpfreaks.com/topic/241083-passing-php-variable-through-url/#findComment-1238354 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.