js删除数据弹出确认删除的提示信息

通过链接来删除的就这样写

<a href="del.aspx?id=1" οnclick="return confirm('确定删除该记录吗?')">删除</a>

通过按钮来删除的就这样写

<input class="button" type="button" name="Sub" value="批量删除" οnclick="DelFromLst();">

<script type="text/javascript">
<!--
function DelFromLst(){
	if(confirm('确认删除已选择数据吗?')){
		document.selform.action.value='batdel';
		document.selform.submit();
	}
}
-->
</script>

注意这里的按钮是 button类型的,不是submit。

当然程序还是建议保持数据的完整性,不彻底删除数据,用一个字段来做标识,例如删除后到垃圾箱,然后可以再恢复就更好了。

转载于:https://www.cnblogs.com/40ps/archive/2011/04/30/2033249.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,这个商品管理页面可以通过 Vue.js 来进行开发。其中需要考虑的页面元素有: 1. id: 商品的唯一标识符 2. 商品名称:商品的名称 3. 单价 price:商品的单价 4. 数量 num:商品的数量 同时,页面需要支持以下操作: 1. 展示数据:展示已有的商品数据 2. 增加:添加新的商品数据 3. 修改回显:在页面上回显某个商品的信息,可以进行修改 4. 删除提示:在删除某个商品时,需要给用户一个确认操作的提示。 下面是一个简单的 Vue.js 代码示例,可以作为参考: ```html <template> <div> <h1>商品管理页面</h1> <table> <thead> <tr> <th>id</th> <th>商品名称</th> <th>单价</th> <th>数量</th> <th></th> </tr> </thead> <tbody> <tr v-for="item in items" :key="item.id"> <td>{{ item.id }}</td> <td>{{ item.name }}</td> <td>{{ item.price }}</td> <td>{{ item.num }}</td> <td> <button @click="editItem(item)">编辑</button> <button @click="deleteItem(item)">删除</button> </td> </tr> </tbody> </table> <h2 v-if="editingItem">修改商品信息</h2> <form v-if="editingItem" @submit.prevent="saveItem"> <label> 商品名称: <input type="text" v-model="editingItem.name" /> </label> <br /> <label> 单价: <input type="number" v-model="editingItem.price" /> </label> <br /> <label> 数量: <input type="number" v-model="editingItem.num" /> </label> <br /> <button type="submit">保存</button> </form> <h2>添加商品</h2> <form @submit.prevent="addItem"> <label> 商品名称: <input type="text" v-model="newItem.name" /> </label> <br /> <label> 单价: <input type="number" v-model="newItem.price" /> </label> <br /> <label> 数量: <input type="number" v-model="newItem.num" /> </label> <br /> <button type="submit">添加</button> </form> </div> </template> <script> export default { data() { return { items: [ { id: 1, name: '商品1', price: 10, num: 100 }, { id: 2, name: '商品2', price: 20, num: 50 }, { id: 3, name: '商品3', price: 30, num: 20 }, ], newItem: { name: '', price: 0, num: 0, }, editingItem: null, }; }, methods: { addItem() { // 为新商品生成一个唯一的 id const id = this.items.length + 1; this.items.push({ id, ...this.newItem }); // 清空新商品表单 this.newItem = { name: '', price: 0, num: 0 }; }, editItem(item) { // 将要编辑的商品信息保存到 editingItem 中 this.editingItem = { ...item }; }, saveItem() { // 找到原来的商品信息,替换成编辑后的商品信息 const index = this.items.findIndex((item) => item.id === this.editingItem.id); this.items.splice(index, 1, this.editingItem); // 清空编辑商品表单 this.editingItem = null; }, deleteItem(item) { if (confirm('确定删除该商品吗?')) { // 找到要删除的商品信息,从列表中删除 const index = this.items.findIndex((i) => i.id === item.id); this.items.splice(index, 1); } }, }, }; </script> ``` 在这个示例中,我们使用了一个 items 数组来保存已有的商品信息。在表格中使用 v-for 指令来遍历这个数组,将每个商品信息渲染到表格中。 当用户点击“编辑”按钮时,我们将要编辑的商品信息保存到 editingItem 中,并显示一个表单,允许用户修改商品信息。当用户点击“保存”按钮时,我们找到原来的商品信息,替换成编辑后的商品信息。 当用户点击“删除”按钮时,我们使用 confirm 函数弹出一个提示框,让用户确认是否要删除该商品。如果用户点击“确定”,我们找到要删除的商品信息,并从列表中删除。 当用户要添加新的商品时,我们显示一个包含表单的区域,允许用户输入商品信息。当用户点击“添加”按钮时,我们为新商品生成一个唯一的 id,并将其添加到 items 数组中。 需要注意的是,这个示例只是一个简单的 Vue.js 代码示例,实际开发中可能需要进行更多的定制化,例如通过接口从后台获取数据

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值