darkfreaks Posted September 23, 2007 Share Posted September 23, 2007 ok so i have this code in javascript when clicked it will expand or collapse a div. right now everything is collapsed. the link aint working right. the link is <a href="javascript:poptoggle(' block01');"> the link i want it to expand is the country link but already has stuff in it for href. i want to know how i would include the javascript code with the php variables and have it work and not conflict with the php. <a href="<?php echo $country_url; ?>" class="citylist_country" > Quote Link to comment https://forums.phpfreaks.com/topic/70319-solved-including-java-code-in-html-link-with-php-syntax/ Share on other sites More sharing options...
marcus Posted September 23, 2007 Share Posted September 23, 2007 If the country url variable has single quotes, use addslashes while echoing. $country_url = "omg i'm cool"; # having that defined echo out the js. <a href="javascript:poptoggle('<?php echo addslashes($country_url); ?>')" class="citylist_country"> Quote Link to comment https://forums.phpfreaks.com/topic/70319-solved-including-java-code-in-html-link-with-php-syntax/#findComment-353257 Share on other sites More sharing options...
darkfreaks Posted September 23, 2007 Author Share Posted September 23, 2007 um now it poptoggles the country url? its sposed ot poptoggle block01 however i found country url defined $country_url = "?cityid=-$country[countryid]&lang=$xlang"; Quote Link to comment https://forums.phpfreaks.com/topic/70319-solved-including-java-code-in-html-link-with-php-syntax/#findComment-353258 Share on other sites More sharing options...
darkfreaks Posted September 23, 2007 Author Share Posted September 23, 2007 can anyone help me fix this so the coutry url link also has the javascript toggle with block1 as the toggle so when clicked on it expands the city url? ??? i tried <a href=javascript:poptoggle('block01");"<?php echo $country_url; ?>"> but it doesnt work? Quote Link to comment https://forums.phpfreaks.com/topic/70319-solved-including-java-code-in-html-link-with-php-syntax/#findComment-353486 Share on other sites More sharing options...
darkfreaks Posted September 23, 2007 Author Share Posted September 23, 2007 ok now it is <a href="javascript:poptoggle('block01');<?php echo $country_url; ?>" class="citylist_city"> but when i hover the country it appears as javascript:poptoggle('block01');?cityid=-38&lang=english and when i click it it does nothing and on the bottom task bar says "error on page" Quote Link to comment https://forums.phpfreaks.com/topic/70319-solved-including-java-code-in-html-link-with-php-syntax/#findComment-353517 Share on other sites More sharing options...
darkfreaks Posted September 23, 2007 Author Share Posted September 23, 2007 is there even a fix for this? ??? Quote Link to comment https://forums.phpfreaks.com/topic/70319-solved-including-java-code-in-html-link-with-php-syntax/#findComment-353534 Share on other sites More sharing options...
BlueSkyIS Posted September 23, 2007 Share Posted September 23, 2007 if i understand correctly, you have an A link with an href defined but you also want to run javascript when it's clicked?? if so, add an onclick handler to your link, ala: <A href='http://www.blueskyis.com' onclick='javascript:poptoggle(' block01');'> Quote Link to comment https://forums.phpfreaks.com/topic/70319-solved-including-java-code-in-html-link-with-php-syntax/#findComment-353548 Share on other sites More sharing options...
darkfreaks Posted September 23, 2007 Author Share Posted September 23, 2007 i cant get it to work i get mysql_connect_db cant connect to the db. but i think there server is down. Quote Link to comment https://forums.phpfreaks.com/topic/70319-solved-including-java-code-in-html-link-with-php-syntax/#findComment-353553 Share on other sites More sharing options...
darkfreaks Posted September 23, 2007 Author Share Posted September 23, 2007 now it doesnt do anything when i put onclick='javascript:poptoggle('block01');' i dont understand it collapses the div tag on page load but doesnt expand it onclick? it is still giving me "error on page" BS on the botton of the page and doesnt expand the div? Quote Link to comment https://forums.phpfreaks.com/topic/70319-solved-including-java-code-in-html-link-with-php-syntax/#findComment-353554 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.