0

そのため、ライブチャットボックスのテーブルにスリムスクロールを追加しようとしていますが、何をしてもうまくいきません。私があなたに提供しているソースには、私の失敗を指摘するだけの意味がないので、それを追加する試みは含まれていません.

Chatbox.php

   <?php include_once("@header/header.php"); ?>
<div class="wraper container-fluid">
<div class="page-title"> </div>
<div class="row">
    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2>Shoutbox <small>Support is not provided here; open a ticket. <strong>NO ADVERTISING, NO SPAMMING</strong></small></h2>
                <?php
                    $viewUsers = $odb->prepare("SELECT `rank` FROM `users` WHERE `username` = :username");
                    $viewUsers->execute(array(':username' => $_SESSION['username']));
                    $rank = $viewUsers->fetch(PDO::FETCH_ASSOC);
                    if($rank['rank'] == 1) {
                    ?>
                <div class="panel-actions">
                    <button type="button" id="clear" onclick="clearchat()" class="btn btn-danger btn-sm">Clear</button>
                </div>
                <?php
                    }
                    ?>
            </div>
            <div id="logs" style="overflow: hidden; width: auto; height: 450px;">
                <table id="chatlogs" class="table table-hover">
                    <tr>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="panel-footer">
                <div class="input-group">
                    <input type="text" id="message" class="form-control" placeholder="Message here..">
                    <span class="input-group-btn"><button type="button" id="send" onclick="send()" class="btn btn-primary">Send</button></span>
                    <input type="hidden" id="username" value="<?php echo $_SESSION['username']; ?>">
                </div>
            </div>
        </div>
    </div>
</div>
<?php include_once("@header/footer.php"); ?>
<script>
    function clearchat() {

      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
          document.getElementById("message").innerHTML = xhttp.responseText;
        }
      };
      xhttp.open("POST", "@ajax/clearchat.php", true);
      xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xhttp.send();
    }
</script>
<script>
    function send() {
      var message=$('#message').val();
      var username=$('#username').val();

      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
          document.getElementById("message").innerHTML = xhttp.responseText;
        }
      };
      xhttp.open("POST", "@ajax/sendmessage.php", true);
      xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xhttp.send("message=" + message + "&username=" + username);

      $('#message').val('');
    }
</script>
<script language="JavaScript"> 
    $('#chatlogs').load("@ajax/shoutbox.php").fadeIn("slow");
       setInterval("updateContent();", 1000 ); 
       function updateContent() 
        { 
             $('#chatlogs').load("@ajax/shoutbox.php").fadeIn("slow"); 
        } 
</script>
<script>
    $(document).ready(function(){
        $('#message').keypress(function(e){
          if(e.keyCode==13)
          $('#send').click();
        });
    });
</script>
4

3 に答える 3