weixin_33691817 2017-03-08 07:04 采纳率: 0%
浏览 29

PHP AJAX按钮单击计数器

i want to make a button click counter. When you click the button the text from it changes, when the button is clicked i want to write to the database but i can't manage this.

<button type="button" class="btn btn-info" style="width:90%;" id="textChanger" onclick="counter;"><h4><i class="glyphicon glyphicon-earphone" aria-hidden="true">  </i> XXXX XXX XXX <h6>Show Number</h6></h4></button>

document.getElementById("textChanger").onclick= function(){
        document.getElementById("textChanger").innerHTML="<h4><i class=\"glyphicon glyphicon-earphone\" aria-hidden=\"true\">  </i> <?php echo $nrTelefonAnunt ?> </h4>";
         }

this is the code that i manage the text change, now what can i do to write to the database, i tried some methods but none worked

  • 写回答

3条回答 默认 最新

  • csdnceshi62 2017-03-08 07:15
    关注

    Try this

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <button type="button" class="btn btn-info" style="width:90%;" id="textChanger" onclick="counter;">1</button>
    <script>
    document.getElementById("textChanger").onclick= function(){
            var count = document.getElementById("textChanger").innerHTML;
            count = parseInt(count) + 1;
            document.getElementById("textChanger").innerHTML=count;
             }
    </script>

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行