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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.