0

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

Edited by Reverend Jim: Fixed formatting

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by R0bb0b
0
<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>

Edited by R0bb0b: n/a

This topic has been dead for over six months. 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.