Jump to content

[SOLVED] Including java code in html link with php syntax


darkfreaks

Recommended Posts

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" >

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">

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?

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"

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');'>

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.