4
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by diafol
0

Indeed it is:

<?
echo "<a href=\"YOUR_LINK_HERE\" >LINK_TITLE_HERE</a>";
?>

P.s: Don't forget the backslashes for the 'href' attribute, if you leave them out the php won't work.

0

Thankyou for that but i still can't get it working now it doesn't even change when i click the link.

I have a image map link that i click which i want to change what is in a div further down the page but what i want in the div is a list of files with links to them i can get plain text just not links

Matthew

0

If I'm getting you, you want to change the content of a part of the page when you click a link. If so you'll probably want Ajax, although you could use an iframe, or even a page reload with url parameters.

An image map is just a glorified bunch of image links, so it/they should work as stated by Menster. If an imagemap link doesn't work, be sure to check the html syntax - all the t's crossed and all the i's dotted!

<?php
echo '<a href="YOUR_LINK_HERE" >LINK_TITLE_HERE</a>';
?>

You could try the above (Menster's e.g. but without escaped double quotes).

0

That hasnt worked either, if you hadnt guessed as well i am new to this. I have attached the code for the whole page. could it be something wrong with the script for the div

otherwise think i might look into this iframe and ajax

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<!-- php code start -->
<? 
 
$table_env01='help';

?>
<!-- php code end -->

<html>

<head>
	<script type="text/javascript" src="swfobject.js"></script>
</head>

<style>
	div, a { 
		padding:3px;
		margin:3px 3px 3px 3px;}
	#scriptVars1 {
		text-align:Left;
		font:Arial;
		width:635px; 
		height:240px;}
</style>
 
<script>
	function changeDivContent( nameOfDiv, newContent )
	{
		var div = document.getElementById( nameOfDiv );
		if( div )
		{
			div.innerText = newContent;
		}
	}
</script>

<body>
<table width="528" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="384" align="center"><img src="Environmental Pie Chart.jpg" width="344" height="343" border="0" usemap="#Map" /></td>
    <td width="20">&nbsp;</td>
    <td width="124"><img src="Environmental Green Boxes.jpg" width="124" height="255" border="0" usemap="#Map3" /></td>
  </tr>
  <tr>
    <td width="384" height="20">&nbsp;</td>
    <td width="20">&nbsp;</td>
    <td width="124" height="20">&nbsp;</td>
  </tr>
  <tr>
    <td width="384" align="center"><img src="Environmental Grey Boxes.jpg" width="384" height="125" border="0" usemap="#Map2" /></td>
    <td width="20">&nbsp;</td>
    <td width="124">&nbsp;</td>
  </tr>
</table>

<br />

<table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div id="scriptVars1">This content should be replaced...</div></td>
  </tr>
</table>

<p>
  <map name="Map" id="Map">
    <area shape="poly" coords="170,9,170,95,141,101,113,122,45,70,60,54,80,38,99,26,122,17,145,11" href="#" onclick=
    "changeDivContent( 'scriptVars1', '<?php
		echo '<a href="http://mydomain.com">My domain</a>';
      ?>' )">
  </map>
  
  <map name="Map2" id="Map2">
  </map>
  
  <map name="Map3" id="Map3">
    <area shape="rect" coords="0,0,124,60" href="#" />
    <area shape="rect" coords="0,65,124,125" href="#" />
    <area shape="rect" coords="0,130,124,190" href="#" />
    <area shape="rect" coords="0,195,124,255" href="#" />
  </map>
</p>
</body>
</html>
0

echo '<a href="http://mydomain.com">My domain</a>' This bit may cause problems - I didn't realise that you were passing this as a parameter in a js call. You need to encode the tag, or better still, just pass the url string (mydomain.com):

Like this: ... onclick="changeDivContent('scriptVars1','<?php echo $url;?>','<?php echo $label;?>');" ... and change this to:

<script>
	function changeDivContent( nameOfDiv, newContent, newLabel )
	{
		var div = document.getElementById( nameOfDiv );
		if( div )
		{
			div.innerText = '<a href="http://' + newContent + '">' + newLabel + '</a>' ;
		}
	}
</script>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.