0

Hello,
I have this part of php code...

<?php 
$dom = new DomDocument();
$dom->load("anna.xml");
$xp = new domxpath($dom);
$unitid = $xp->query("/ead/archdesc/dsc/c01/did/unitid");
foreach ($unitid as $check) 
{
	print 	'<a href="#" onClick="displayResult2(' . $check->textContent . ')">'  . $check->textContent . ' </a>'; // I presented the unitid's of a xml file and made them clickable.
	print 	 "<br/>"; 
	
	}
	
?>

and

function displayResult2(id) 
{
	alert(id);
}

when I click an unitid, The alert message doesn't work :(
what's wrong? (i'm newbie to javascript/php/....)

3
Contributors
5
Replies
7
Views
7 Years
Discussion Span
Last Post by renoua
0

When the links appear, what underlined values do you see?
Is other javascript on the page working?

Edited by fxm: n/a

0

they seem to be links but when i pass the mouseover then don't even underline.. so the php syntax is wrong but I don't know how to correct it..

print 	'<a href="#" onClick="displayResult2(' . $check->textContent . ')">'  . $check->textContent . ' </a>';

Yes, I have some other javascript which is working.

0

well I found the solution
the code that works is :

echo    "<a href=\"#\" onClick=\"displayResult2('$check->textContent')\"> $check->textContent </a>";

thanks for your help anyway :) :) :)

This question has already been answered. 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.