Hi, is there any way I can execute my PHP coding when my html image is clicked? Through AJAX, HTML, Javascript or anything.

Right now my coding looks like this in Dreamweaver:

<img src="_images/banner1.jpg" width="286" height="60" border="0" usemap="#Map" class="apply-btn" style="float:center; padding-top:20px; padding-left:240px;" onclick=
"hello()" value='Applyonclick' input name='Applyonclick'/>
</form>
<script type="application/javascript">

function hello()
{
    alert("Hello It works");
<?php
if (isset($_POST['Applyonclick']))
{
    $icmp1 = "icmp1.txt";
    $value = exec ("snmpset -v 2c -c private 172.16.164.188                 .1.3.6.1.4.1.9.2.1.53.172.16.164.187 string $icmp1 ");

}
?>
}
</script>

I know I'm not doing the right way but I don't really know how it works so I'm trying out all sorts of things.

Regards

<a href=xxx.php><img src="_images/banner1.jpg"></a>
<html>
    <head>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
    </head>
    <body>
        <script type="text/javascript" language="javascript">
            function callPHPScript()
            {
                $.ajax(
                {
                    url:'scriptFileName.php',
                    type:'GET',
                    success:function(response)
                    {
                        alert(response); // or do what ever else you might want to do here
                    }
                });
            }

            $(document).ready(function()
            {
                $("#imgID").click(function(){
                    callPHPScript();
                });
            });
        </script>

        <img id="imgID" src="test.jpg" height="50" width="50" />
    </body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.