<input type="file" onchange="previewImage(this)" onclick="selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <button onclick="deleteImage(this.parentNode)">删除</button> </td>添加后点击时报错

时间: 2023-10-09 08:08:20 浏览: 36
你在添加删除按钮的代码中出现了一个错误。在同一个元素上不能重复使用相同的事件属性,例如 `onclick`。为了修复这个问题,你可以将删除按钮的 `onclick` 事件合并到 `selectCell()` 函数中。 以下是修改后的示例代码: ```html <td> <input type="file" onchange="previewImage(this); selectCell(this);" style="width: 100px; height: auto;"> <button onclick="deleteImage(this.parentNode)">删除</button> </td> ``` 在这个示例中,我们将删除按钮的 `onclick` 事件合并到了 `selectCell()` 函数中。当单元格被选中时,会触发 `selectCell()` 函数,并且在该函数内部处理删除按钮的点击事件。 请确保你已经定义了 `deleteImage()` 函数来处理删除按钮的逻辑。 希望这样解决了问题!如果还有其他疑问,请随时提问。
相关问题

<input type="file" onchange="previewImage(this)" onclick="selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)" onclick="selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)" onclick="selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)" onclick="selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)" onclick="selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td>这是我添加图片的按钮,需要怎么修改

根据你提供的代码,你想要在点击图片上传按钮时显示一个弹出窗口来展示图片。然而,你的代码中有一个问题,即重复使用了 `onclick` 属性。为了解决这个问题,你可以将 `onclick` 事件合并成一个,并将弹出窗口的逻辑添加到 `selectCell()` 函数中。 以下是修改后的示例代码: ```html <td> <input type="file" onchange="previewImage(this); selectCell(this);" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this); selectCell(this);" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this); selectCell(this);" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this); selectCell(this);" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this); selectCell(this);" style="width: 100px; height: auto;"> </td> ``` 在这个修改后的示例中,我们将 `onclick` 属性移除,并合并为一个 `onchange` 事件。同时,我们在 `onchange` 事件中调用了 `previewImage(this)` 和 `selectCell(this)` 函数。 然后,你可以在 `selectCell()` 函数中添加弹出窗口的逻辑来展示图片。具体的实现方式取决于你使用的弹出窗口组件或自定义的方法。你可以根据你的具体需求来实现弹出窗口的逻辑。 希望这能帮到你!如果还有其他问题,请随时提问。

<td contenteditable="true" ><input type="text" oninput="filterTable(1)" placeholder="aoiStep" ></td> <td contenteditable="true" ><input type="text" oninput="filterTable(2)" placeholder="defectType" ></td> <td contenteditable="true" ><input type="text" oninput="filterTable(3)" placeholder="layerCode" ></td> <td contenteditable="true" ><input type="text" oninput="filterTable(4)" placeholder="type"></td> <td contenteditable="true" ><input type="text" oninput="filterTable(5)" placeholder="dpet" ></td> <td contenteditable="true"><input type="text" oninput="filterTable(6)" placeholder="subcode" ></td> <td contenteditable="true" ><input type="text" placeholder="codeDescription" ></td> <td contenteditable="true" >image1</td> <td contenteditable="true" >image2</td> <td contenteditable="true">image3</td> <td contenteditable="true" >image4</td> <td contenteditable="true" >image5</td> <td contenteditable="true" ><input type="text" placeholder="determination_rule"></td> </tr> </thead> <tbody> <tr> <td contenteditable="true" onclick="selectCell(this)">ACT</td> <td contenteditable="true" onclick="selectCell(this)">Particle</td> <td contenteditable="true" onclick="selectCell(this)">ACT</td> <td contenteditable="true" onclick="selectCell(this)">Particle</td> <td contenteditable="true" onclick="selectCell(this)">ACT</td> <td contenteditable="true" onclick="selectCell(this)">Particle</td> <td contenteditable="true" onclick="selectCell(this)">ACT</td> <td> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <td> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td contenteditable="true" onclick="selectCell(this)">Particle</td> 这我的表头,以及表格填充行,我需要怎么为以下格式<form action="upload.php" method="POST" enctype="multipart/form-data"> <!-- 表单内容 --> <input type="file" name="image1"> <!-- 其他字段 --> <button type="submit">提交</button> </form>

根据你提供的代码,你想要为每个图片上传字段添加一个文件选择框,并在提交表单时将上传的图片保存到对应的字段中。下面是一个示例,展示如何对你提供的代码进行修改: ```html <form action="upload.php" method="POST" enctype="multipart/form-data"> <table> <thead> <tr> <th>aoiStep</th> <th>defectType</th> <th>layerCode</th> <th>type</th> <th>dpet</th> <th>subcode</th> <th>codeDescription</th> <th>image1</th> <th>image2</th> <th>image3</th> <th>image4</th> <th>image5</th> <th>determination_rule</th> </tr> </thead> <tbody> <tr> <td contenteditable="true"><input type="text" name="aoiStep" placeholder="aoiStep"></td> <td contenteditable="true"><input type="text" name="defectType" placeholder="defectType"></td> <td contenteditable="true"><input type="text" name="layerCode" placeholder="layerCode"></td> <td contenteditable="true"><input type="text" name="type" placeholder="type"></td> <td contenteditable="true"><input type="text" name="dpet" placeholder="dpet"></td> <td contenteditable="true"><input type="text" name="subcode" placeholder="subcode"></td> <td contenteditable="true"><input type="text" name="codeDescription" placeholder="codeDescription"></td> <td><input type="file" name="image1" style="width: 100px; height: auto;"></td> <td><input type="file" name="image2" style="width: 100px; height: auto;"></td> <td><input type="file" name="image3" style="width: 100px; height: auto;"></td> <td><input type="file" name="image4" style="width: 100px; height: auto;"></td> <td><input type="file" name="image5" style="width: 100px; height: auto;"></td> <td contenteditable="true"><input type="text" name="determination_rule" placeholder="determination_rule"></td> </tr> </tbody> </table> <button type="submit">提交</button> </form> ``` 在这个修改后的代码中,我将上传图片的文件选择框添加到每个对应的字段中,并为每个文件选择框添加了 `name` 属性,确保在提交表单时能够正确传递对应的文件数据。 请注意,你需要根据实际情况修改表格的样式和布局,以及表单的目标 URL(`action` 属性)和其他字段。 当你提交表单时,所选图片将会被上传到 `upload.php` 脚本中进行处理。你可以在 `upload.php` 中使用 PHP 代码来处理图片上传并将文件保存到服务器或数据库中。 希望这个回答对你有帮助!如果你还有其他问题,请随时提问。

相关推荐

<input type="text" oninput="filterTable(1)" placeholder="aoiStep" > <input type="text" oninput="filterTable(2)" placeholder="defectType" > <input type="text" oninput="filterTable(3)" placeholder="layerCode" > <input type="text" oninput="filterTable(4)" placeholder="type"> <input type="text" oninput="filterTable(5)" placeholder="dpet" > <input type="text" oninput="filterTable(6)" placeholder="subcode" > <input type="text" placeholder="codeDescription" > image1 image2 image3 image4 image5 <input type="text" placeholder="determination_rule"> ACT Particle ACT Particle ACT Particle ACT <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> Particle 这我的表头,以及表格填充行,我现在需要在保持我现有的功能情况下需要对表格进行修改为以下格式,确保数据能偶提交保存到数据库内,并且能将图片行图片保存在电脑本地,后将图片路径保存在数据库内<form action="upload.php" method="POST" enctype="multipart/form-data"> <input type="file" name="image1"> <button type="submit">提交</button> </form>

for (var i = 0; i < cellsCount; i++) { var newCell = newRow.insertCell(); newCell.contentEditable = true; var previousCell = previousRow.cells[i]; // 获取上一行对应列的单元格 var previousInput = previousCell.querySelector('input[type="text"]'); if (previousInput) { var newTextArea = document.createElement("textarea"); newTextArea.name = previousInput.name; newCell.appendChild(newTextArea); } else if (previousCell.querySelector('input[type="file"]')) { var newImageInput = document.createElement("input"); newImageInput.type = "file"; newImageInput.name = previousCell.querySelector('input[type="file"]').name; // 继承上一行对应列的文件输入框属性 newImageInput.onchange = function () { previewImage(this); }; newImageInput.onclick = function () { showPopup(this.src); }; newCell.appendChild(newImageInput); } else { var newTextArea = document.createElement("textarea"); newTextArea.name = "yourTextareaName"; // 替换为你的文本框名称 newCell.appendChild(newTextArea); }这是我新增按钮行按钮的代码,<textarea name="aoi_step">3</textarea> <textarea name="defect_type">Particle</textarea> <textarea name="layer_code">ACT</textarea> <textarea name="type">Particle</textarea> <textarea name="dpet">ACT</textarea> <textarea name="subcode">Particle</textarea> <textarea name="code_description">ACT</textarea> <input type="file" name="image1_path" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <input type="file" name="image2_path" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <input type="file" name="image3_path" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <input type="file" name="image4_path" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <input type="file" name="image5_path" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <input type="text" name="determination_rule" value="ACT"> 这是我的表格,在我新增单元格时,是要将对应列的类名添加到新增的单元格,并使文本框不可拖动改变大小

最新推荐

recommend-type

安装NumPy教程-详细版

附件是安装NumPy教程_详细版,文件绿色安全,请大家放心下载,仅供交流学习使用,无任何商业目的!
recommend-type

语音端点检测及其在Matlab中的实现.zip

语音端点检测及其在Matlab中的实现.zip
recommend-type

C#文档打印程序Demo

使用C#完成一般文档的打印,带有页眉,页脚文档打印,表格打印,打印预览等
recommend-type

DirectX修复工具-4-194985.zip

directx修复工具 DirectX修复工具(DirectX repair)是系统DirectX组件修复工具,DirectX修复工具主要是用于检测当前系统的DirectX状态,若发现异常情况就可以马上进行修复,非常快捷,使用效果也非常好。
recommend-type

Python手动实现人脸识别算法

人脸识别的主要算法 其核心算法是 欧式距离算法使用该算法计算两张脸的面部特征差异,一般在0.6 以下都可以被认为是同一张脸 人脸识别的主要步骤 1 获得人脸图片 2 将人脸图片转为128D的矩阵(这个也就是人脸特征的一种数字化表现) 3 保存人脸128D的特征到文件中 4 获取其他人脸转为128D特征通过欧式距离算法与我们保存的特征对比,如果差距在0.6以下就说明两张脸差距比较小
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

解答下列问题:S—>S;T|T;T—>a 构造任意项目集规范族,构造LR(0)分析表,并分析a;a

对于这个文法,我们可以构造以下项目集规范族: I0: S -> .S S -> .T T -> .a I1: S -> S. [$ T -> T. [$ I2: S -> T. I3: S -> S.;S S -> S.;T T -> T.;a 其中,点(.)表示已经被扫描过的符号,;$表示输入串的结束符号。 根据项目集规范族,我们可以构造出LR(0)分析表: 状态 | a | $ ---- | - | - I0 | s3| I1 | |acc I2 | | 其中s3表示移进到状态3,acc表示接受。在分析字符串a;a时,我们可以按照以下步骤进行
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。