<!DOCTYPE html>
        <style type="text/css">
                border-color: blue;
                border-style: inset;
                width: 200px;
        <script type="text/javascript">
            function myfn(var) {
            document.getElementsByTagName("kalyan").onclick= function() {
                param.innerHTML = "Clicked This ";
                alert(' clicked');
            $q="SELECT * FROM products WHERE pname LIKE '$t%'";
                    echo " No result Found ";
                        <div id='kalyan' class="bor">
                            <a href="#" id="<?php echo $row['pid']; ?>" onClick="myfn('kalyan')" > 
                                <?php echo $row['pname']." ".$row['pid']; ?>
                echo " No result Found ";

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

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.