Click here to Skip to main content
15,891,781 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a php page which includes html controls. I just want to define a js function and call it onclick event of an html control,img. But , it does not work. When I try to call js function at click event of image in html page, it works well.

Could you please help about this?

The page is like below as simplified;

PHP
<?php 

?>


<script type="text/javascript">
function testFunction(url, title, width, height){

	window.open(url,title,width,height);

}

</script>


<ul class="block_listing">
	<li>		
		<div class="block_listing_image">
			<img src="smiley.gif" alt="Smiley face" height="42" width="42"  önclick="testFunction("url","title",150,100);">
			
		</div>
        </li>
</ul> 


The page name is ended with mypage.html.php

Thanks in advance for your help,
Kind Regards,
Posted
Updated 6-Nov-13 22:58pm
v2
Comments
thanh_bkhn 7-Nov-13 5:25am    
I noticed your onclick event is written as "önclick". Is that the reason?
no_-_namee 7-Nov-13 5:33am    
Thanks for the reply, but I've edited in notepad this code. I should have changed it like that. I am sure it is written like "onclick" as it should be

1 solution

At least one of your problems:

önclick="testFunction("url","title",150,100);"


Notice that you have double quotes inside of double quotes!

For a start, try:

onclick="testFunction('url','title',150,100)"


Aside:
The parsers will love you for it! As written, why did you make this a php page when you don't use any php?

 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900