当onclick on div并且无法将参数化链接作为innerHTML时,无法将字符串从php传递到javascript

I want to load a file when on click on the different text in another div. I have 5 div. And also I need to fix some default content in all the div. div should override and call the file when clicking on the text which is in another div. I am able to call two files in two different files when I click on the text in the left div. But when I try to pass a string from PHP to javascript I am not able to do that. I want to parameterize the link to the different text. How can I achieve this? If I try to assign a PHP variable to it is giving nothing in output. Thanks in advance.

 <html>
<head>
    <title>A div layout</title>
</head>

<body>

    <script>
            function load_home(link){

                document.write(link);

                var project="<?php echo $name; ?>";

                var table_link='table_'+link+'.php';

                var graph_link='graph_'+link+'.php';


                document.getElementById("tables").innerHTML='<object type="type/html" data="table_link" height=100% width=100%></object>';
                document.getElementById("graph").innerHTML='<object type="type/html" data="graph_link" height=100% width=100%></object>';

            }
    </script>

    <div id="header" style="width: 100%; height:7%; background-color: green; color: white;">Merahkee Tech Solutions
    </div>

    <div id="tree" style="width: 20%; height:88%; background-color: pink; color: white; float:left">
    <?php
    $name="customer";
        echo '<nav>
          <ul>
            <li><a href ="#" onclick="load_home('.$name.')">Pebble</a></li>
            <li><a href ="#" onclick="load_home()">Jenkins</a></li>
            <li><a href ="#" onclick="load_home()">Tomcat</a></li>
            <li><a href ="#" onclick="load_home()">Jira</a> </li>
          </ul>
        </nav>'
    ?>
    </div>

    <div id="tables" style="width: 80%; height:35%; background-color: skyblue; color: white; float:left">This is default content

    </div>

    <div id="graph" style="width: 70%; height:53%; background-color: lightblue; color: white; float:left">This is trial graph div
    </div>

    <div id="dropdown" style="width: 10%; height:53%; background-color: pink; color: white; float:left">This is trial dropdown div
    </div>

    <div id="footer" style="width: 100%; height:5%; background-color: green; color: white; float:left">This is a footer div
    </div>


</body>

Now I am not getting anything once I click on text in the first div.

You need to put your string in ' or " when you pass it to the javascript function so the function know that you are sending string so you instead of :

echo '<nav>
          <ul>
            <li><a href ="#" onclick="load_home('.$name.')">Pebble</a></li>
            <li><a href ="#" onclick="load_home()">Jenkins</a></li>
            <li><a href ="#" onclick="load_home()">Tomcat</a></li>
            <li><a href ="#" onclick="load_home()">Jira</a> </li>
          </ul>
        </nav>';

you Do:

echo "<nav>
          <ul>
            <li><a href =\"#\" onclick=\"load_home('{$name}')\">Pebble</a></li>
            <li><a href =\"#\" onclick=\"load_home()\">Jenkins</a></li>
            <li><a href =\"#\" onclick=\"load_home()\">Tomcat</a></li>
            <li><a href =\"#\" onclick=\"load_home()\">Jira</a> </li>
          </ul>
        </nav>";

And put your script in the end of your body

<html>
<head>
    <title>A div layout</title>
    <script type="text/javascript">
        function load_home(link) {

            document.write(link);

            var project=link;

            var table_link='table_'+link+'.php';
            var graph_link='graph_'+link+'.php';


            document.getElementById("tables").innerHTML='<object type="type/html" data="table_link" height=100% width=100%></object>';
            document.getElementById("graph").innerHTML='<object type="type/html" data="graph_link" height=100% width=100%></object>';

        }
    </script>
</head>

<body>

    <div id="header" style="width: 100%; height:7%; background-color: green; color: white;">
        Merahkee Tech Solutions
    </div>

    <div id="tree" style="width: 20%; height:88%; background-color: pink; color: white; float:left">

        <?php $name = "customer"; ?>
        <nav>
            <ul>
                <li><a href ="#" onclick="load_home('<?php echo $name ?>');">Pebble</a></li>
                <li><a href ="#" onclick="load_home('<?php echo $name ?>');">Jenkins</a></li>
                <li><a href ="#" onclick="load_home('<?php echo $name ?>');">Tomcat</a></li>
                <li><a href ="#" onclick="load_home('<?php echo $name ?>');">Jira</a></li>
            </ul>
        </nav>
    </div>

    <div id="tables" style="width: 80%; height:35%; background-color: skyblue; color: white; float:left">
        This is default content
    </div>

    <div id="graph" style="width: 70%; height:53%; background-color: lightblue; color: white; float:left">
        This is trial graph div
    </div>

    <div id="dropdown" style="width: 10%; height:53%; background-color: pink; color: white; float:left">
        This is trial dropdown div
    </div>

    <div id="footer" style="width: 100%; height:5%; background-color: green; color: white; float:left">
        This is a footer div
    </div>
</body>
</html>

In your Snippet, I see single/double quote issue, try pasting my whole snippet.

<li><a href ="#" onclick="load_home('<?php echo $name ?>');">Pebble</a></li>

See '<?php echo $name; ?>' the single quotes around PHP variable being echoed.