dongluan7821 2014-06-14 15:38
浏览 49

如何弹出一个带有文本框的javascript警告框来更新mysql表? [关闭]

I'm making a site that lets people login, buy stuff from the store, etc, I am trying to make it where moderators can change and update their credits by clicking a link and make a popup alert box thing pop up saying to type in how many credits to give them in the popup box, then click "Ok" and update the mysql table with the new amount, how can I do this?

  • 写回答

2条回答 默认 最新

  • douang1243 2014-06-14 16:22
    关注

    For this you have to use JavaScript's prompt function which provides a text box to enter value after getting the value from the user you can make an ajax request to sever to update the new amount in the database.

    Something like this:-

    First add jQuery file in your page.

    <a href="javascript:void(0);" onClick="updateAmount(itemId);">Click here to update amount</a>
    <script>
        function updateAmount(itemId){
            amount = prompt('Enter new amount', 0);
            $.ajax({
                url: updateAmount.php,
               data: {"amount": amount, "id": itemId},
               success: function(data){
                   alert("Amount updated successfully.");
               }
            });
        }
    </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)