如何在单击时更改特定单元格的文本?

时间:2017-09-30 18:04:31

标签: javascript php html css mysql

<tr>
<div id=tableHead>
<th>Poster</th>
<th style="padding-left: 70px;">Destination</th>
<th style="padding-left: 10px;">Takeoff time</th>
<th style="padding-left: 10px; "># of passenger</th>
<th style="padding-left: 35px; ">Post time</th> 
</div>
</tr>


<?php session_start() ; 
    include 'databaseConnection.php' ;
    $sqlCommand3 = "SELECT * FROM posts ;" ;
            $result3 = mysqli_query($conn , $sqlCommand3);
            $resultCheck = mysqli_num_rows($result3);
            while ($row = mysqli_fetch_array($result3)) { ?>
        <tr>
            <td style="padding-left: 10px;"> <?php echo $row['poster']; ?></td>
            <td style="padding-left: 45px;"><?php echo $row['post_destination']; ?></td>
            <td style="padding-left: 30px;"><?php echo $row['post_readyTime']; ?></td>

            <td style="padding-left: 45px;"> <?php  echo $row['post_numberOfPassenger'];   


            ?></td>
            <td style="padding-left: 32px;"><?php echo $row['post_submitTime']; ?></td>


            <td id=joinRow>
                <a href="riderPage.php?edit=<?php echo $row['post_id']; ?>" class="edit_btn " id = "<?php echo $row['post_id']; ?>">Join</a>

            </td>



            <td>
                <a href="riderPage.php?del=<?php echo $row['post_id']; ?>" class="del_btn" id="<?php echo $row['post_id']; ?>">Delete</a>

            </td>

        </tr>
    <?php } ?>



</table>

<script>

var x = document.getElementsByClassName('edit_btn');

    for (var i = 0; i < x.length; i++) {
        x[i].addEventListener("click" , function(){
    x[i].innerHTML = "Joined";
});
    }
</script>   

我想更改&#34;加入&#34;加入&#34;加入&#34; (特定细胞的)每当&#34;加入&#34; (点击该特定单元格)。这是我的源代码,但它不起作用。这段代码有什么问题?怎么解决?非常感谢:)

0 个答案:

没有答案