Hi everyone. I want to make when i press a button to showup a dialog but page to not refresh or if refreshes to showup after that. i have this code but the dialog is going away after clicking the button

<form action="" method="post">
    <div class="col-xs-4 col-md-4">
    <a href="<?= $Link ?>" target="_blank" class="thumbnail">
        <img src="<?= $Image ?>" class="thumb-vote-image" alt="Item">
    </a>
    <h1><button name="<?= $ID ?>" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">VOTE</button></h1>
    <h3><?= $Name ?></h3>
    </div>
</form>

<?php
    if(isset($_POST[$ID])) {
        $vote = $ID;
?>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title"></h4>
        </div>
        <div class="modal-body">
            <center>
                <p>Item 1</p>
                <p>Item 2</p>
                <p>Item 3</p>
            </center>
        </div>
    </div>
</div>
</div>
<?php
}
Member Avatar for diafol

Is it because you've placed the button inside a form and you have not prevented the default action (submit)?
Can't remember if buttons default to submit nor if modal js applies a preventDefault().

Oh god it worked :D i have forgoten to put type="button" in the <button> section :D
Thank you very much :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.