I have a php code
as shown below in which when Line A
and Line B
is executed, I want to display a Not Found
popup message on click.
if (condition) {
/*
code
*/
if (file_exists($path)) {
$choices[0][1] = 'display_file.php?path=' . addressencode($path);
} else {
$choices[0][1] = "Not found"; // Line A
}
continue;
}
if (1 == sizeof($choices)) {
$address = $choices[0][1];
}
<area shape="rect" href="<?php echo $address; ?>"
onclick="if(this.getAttribute('href') !== 'changes need to be made here' && parent.document.body.rows == '*,0' ) parent.document.body.rows = '55%,45%';"
alt="<?php echo implode(', ', $records); ?>" /> <!-- Line B -->
Problem Statement:
I am wondering what changes I need to make at Line A
and especially at Line B
, so that on click Not Found
popup message is displayed.
2
Answers
Try adding this below Line A.
You may attach an event listener on your
<area>
tag to show a popup or perform any operation on the element’s click.The script loads up initially during the page load, but the message is shown only on click and when the
if
condition is satisfied. This way you’ll not have to add the condition in theonclick
attribute of thearea
tag and let JS handle the event by binding a listener to the element.