-3
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <style type="text/css">
            .bor
            {
                border-color: blue;
                border-style: inset;
                width: 200px;
            }
        </style>
        <script type="text/javascript">
            function myfn(var) {
                alert('kalyan');
            }
            document.getElementsByTagName("kalyan").onclick= function() {
                param.innerHTML = "Clicked This ";
                alert(' clicked');
            };
        </script>
    </head>
    <body>
        <?php
            $t=$_REQUEST['word'];
            require_once('config.php');
            $q="SELECT * FROM products WHERE pname LIKE '$t%'";
            if($result=mysqli_query($connection,$q))
            {
                if(mysqli_num_rows($result)==0)
                    echo " No result Found ";
                else
                {
                    while($row=mysqli_fetch_assoc($result))
                    {
                        ?>
                        <div id='kalyan' class="bor">
                            <a href="#" id="<?php echo $row['pid']; ?>" onClick="myfn('kalyan')" > 
                                <?php echo $row['pname']." ".$row['pid']; ?>
                            </a>
                        </div>
                        <?php
                    }
                }
            }
            else
                echo " No result Found ";
            ?>
    </body>
</html>

Here onclick event is unable to call that myfn() function can anyone please help to trace out this error. I'm using this script for AutoCompletion with PHP

closed as off-topic by superfell, Adrian Larson, Mohith Shrivastava, cropredy, Jenny B Oct 1 '15 at 20:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions not specific to Salesforce are off-topic here, but can be asked on Stack Overflow." – superfell, Adrian Larson, Mohith Shrivastava, cropredy, Jenny B
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    This doesn't have anything to do with Salesforce. Try posting your question to Stack Overflow. – Rob Oct 1 '15 at 16:11
  • It also has nothing to do with AJAX... – Adrian Larson Oct 1 '15 at 16:19
1

You are using document.getElementsByTagName("kalyan"), but you do not have any <kalyan> tags. Also, even if your markup did contain this tag, I'm fairly certain you can't just set onclick on the returned collection from that selector.

Not the answer you're looking for? Browse other questions tagged or ask your own question.