รหัสหลัก:
<title> ASP Batch Addition and Express Example </title> <%ถ้า request.form (op) = อัปเดตจากนั้น 'การส่งฟอร์ม IDS = request.form (ids) ถ้า IDS <> response.write ID ของข้อมูล เพื่อลบคอลเลกชัน: & ids & <br> '============= การลบฐานข้อมูลการดำเนินการ conn.execute (ลบจาก XXX โดยที่ ID ใน (& ids &))' ให้ความสนใจกับการตรวจสอบความปลอดภัยด้วยตัวเอง ID นั้นคือการรวบรวมตัวเลขคุณสามารถทำการตัดสิน regexp ปกติด้วยตัวเองความถูกต้องรูปแบบคือ ^/d+(,/d+)*$ สิ้นสุดถ้า rows = request.form (ชื่อ) .count 'รวมถึงเพิ่ม/แก้ไขสำหรับ i = 1 ถึง การเดินทางของ Rows 'ของแต่ละแถวของข้อมูล ID = request.form (id) .item (i) & name = request.form (ชื่อ) .item (i) sex = request.form (เพศ) .item (i) อายุ = คำขอ. : & id & | & name & | sex & | & age & | & addr & <br> method = post onsubmit = ส่งคืนตรวจสอบ (นี่)> <อินพุต type = name hidden = ids /> <!-ใช้เพื่อจัดเก็บการรวบรวม ID เพื่อลบบันทึก-> <อินพุต type = hidden name = op value = update /update / > <table border = 1 id = tb> <tr> <th> ชื่อ </th> <th> เพศ </th> <th> อายุ </th> <th> ที่อยู่ </th> <th> ลบ </th / th> </tr> <! ------------------------------------- ------------------------------------------------------ ------------------------------------------------------ ------------------------------------------------------ ------------------------------------------------------ ------ tr> <td> <อินพุต type = ค่าข้อความ = name1 name = name /> </td> <td> <อินพุต type = text value = gender1 name = sex /> < /td> <td> <อินพุต type = ค่าข้อความ = age1 name = age /> < /td> <td> <type input = text value = address1 name = addr / > </td> <td> <อินพุตประเภท = ปุ่มค่า = ลบ onClick = Removerow (นี่)/> <อินพุตประเภท = ชื่อที่ซ่อน = id value = 1/> </td> </tr> <tr> <td > <อินพุตประเภท = ค่าข้อความ = name2 name = name /> < /td> <td> <ประเภทอินพุต = ค่าข้อความ = gender2 name = เพศ /> </td> <td> <อินพุตประเภท = ค่าข้อความ = age2 name = age/> </td> <td> <อินพุต type = text value = address2 name = addr/> </td> <td> <td> ประเภทอินพุต = ค่าปุ่ม = ลบ onClick = Removerow (นี่)/> <อินพุตประเภท = ชื่อที่ซ่อน = id value = 2/> </td> </tr> <! ------------ ในการแก้ไขตัวอย่างข้อมูล --------> <tr> <td colspan = 5 Align = center> <อินพุตประเภท = submit value = submit/> <input type = button = เพิ่มแถวข้อมูลใหม่ onclick = addrow () /> </td> </tr> </table> </form> <script type = text/javascript> function removerow (btn) {ถ้า (ยืนยัน ('ยืนยันเพื่อลบ? - ')) {var tr = btn.parentnode.parentNode; เบราว์เซอร์มาตรฐาน. value! = '') {// ลบเป็นแถวที่มีอยู่แทนที่จะเป็นใหม่จากนั้น ID จะถูกเก็บไว้ใน IDS btn.form.ids.value += (btn.form.ids.value == ' '? document.getElementById ('tb'), tr = tb.insertrow (tb.rows.length - 1), td = tr.insertcell (0); td = tr.insertcell (1); '; td = tr.insertcell (3); type = ชื่อข้อความ = addr /> '; td = tr.insertcell (4); '; // เพิ่ม ID Data Line ใหม่} การตรวจสอบฟังก์ชั่น (f) {var tb = document.getElementById (' tb '), ipts; <J; tb.rows [i] .getElementsByTagname ('อินพุต'); '); FALSE; '') {Alert ('โปรดป้อนที่อยู่!');