Owl
Owl

Reputation: 689

Two times same onclick function - only one works

I am desperate on this.

I create a list with an image and some description and other data.

The image and the description should be linked the same way.

The description link(onclick event) work fine:

<a href="#" onclick="show_object('<?php echo $itemId."','".$identifier; ?>');  return false;"><?php echo (string)$flat.'</a><br />'; ?>

But around the image it doesn't:

<a href="#" onclick="show_object('<?php echo $itemId.','.$identifier; ?>');return false;">
 <img src="<?php echo (string)$image_url; ?>" class="list_image"></img>
</a>

Why? I do not understand, I tried several other ways, with including the onclick into the image, making a span out of the a.. Nothing works.

If I click on the image, I see in the javascript console that the request get started, but it does not load the page.

I do not understand since the two requests are exact same and immitedly behind another (inside a table)

please help!

Upvotes: 0

Views: 264

Answers (2)

xShirase
xShirase

Reputation: 12389

How is that "exactly the same" ?

"show_object('<?php echo $itemId."','".$identifier; ?>');  return false;"
"show_object('<?php echo $itemId.','.$identifier; ?>');return false;"

I suggest you double check the quotes, or copypaste the working one into the other, then come back to us if it's not fixed :)

Upvotes: 1

Jens
Jens

Reputation: 2075

I think you are missing some quotes:

<a href="#" onclick="show_object('<?php echo $itemId."','".$identifier; ?>');return false;">
 <img src="<?php echo (string)$image_url; ?>" class="list_image"></img>
</a>

In your version, you call show_object('someitemid,someidentifier') but you want to call show_object('someitemid','someidentifier') as you do in your first <a>-tag.

Upvotes: 4

Related Questions