如何通过第一个按钮从PHP启动按钮值+ Bootstrap的模态按钮值

时间:2017-08-26 16:52:24

标签: php jquery html twitter-bootstrap

我希望获得<div class="main"> <div class="login-back-up"> </div> <div class="login-back-down"> <p class="buttons-row hr-login-button-row"> <a href="#" class="button">Button</a> <!--I change it to Button because that--> <a href="#" class="button">Button</a> <!--is on picture of example from OP--> </p> </div> </div>个按钮值,以通过向用户显示确认模式来确认用户的信息。 按钮:

clickMe

PHP:

<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
     <button type="submit" class="btn btn-primary"  value="clickMeValue" name="clickMe">Click Me</button>
</form>

如何在bootstraps模态中获得<?php if (isset($_POST['clickMe'])){ echo "<script>$(document).ready(function(){ $('#confirmModal').modal('show'); });</script>"; // showing modal from php //after shoeing modal from php if(isset($_POST['confirm'])){ echo $_POST['confirm']; echo "<br/>"; echo $_POST['clickMe']; //this is not echoing } } ?> 值确认。

1 个答案:

答案 0 :(得分:0)

为按钮添加ID,然后您可以在此处访问所单击按钮的值..

<button type="submit" id="my-button" class="btn btn-primary"  value="clickMeValue" name="clickMe">Click Me</button>

然后..

$(document).ready(function() { 

    $('#my-button').click(function() {

        var the_value = $(this).val();
        alert(the_value);

    });

});