Bootstrap按钮,如何多次单击

时间:2014-11-25 06:28:31

标签: php twitter-bootstrap button rows

我有一个计数器,根据计数器的内容向表中添加行数。我有一个按钮,每次单击时都会增加计数器,但它只能运行一次。

PHP:

if (isset($_REQUEST['Addmore'])) {      
    $NoOfUsers++;

<form action="addstudent.php">
<th>
    <button type="submit" class="btn btn-default btn-sm spoiler-trigger pull-right" aria-label="Left Align" name="Addmore" title="Add Row">
        <span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"> </span>
    </button>
</th>
</form>

1 个答案:

答案 0 :(得分:0)

<强> PHP

<?php
session_start();
if (isset($_REQUEST['Addmore'])) {
?><button class="btn btn-default"><?php
echo $_SESSION['NoOfUsers'] ? ++$_SESSION['NoOfUsers'] : $_SESSION['NoOfUsers']=1;
?></button><?php
}

JavaScript

<button id="counter" class="btn btn-default">0</button>
<script>
    $('#counter').on('click',function(){$( this ).html(1 * $( this ).html() + 1)});    
</script>