简体   繁体   English

在提交表单之前,如何在警报窗口中显示选定的复选框?

[英]How can I show selected checkboxes in alert window before form submit?

I have a form for editing and deleteing phone directory entries for our office. 我有一个用于编辑和删除我们办公室电话目录条目的表格。 Each line shows the persons' name and phone number etc, and has a checkbox. 每行显示人员的姓名和电话号码等,并带有一个复选框。

The form basically has two buttons, edit and delete. 表单基本上有两个按钮,即编辑和删除。 You go through and select all the rows that you either want edit or delete, and then the form is submitted. 您浏览并选择要编辑或删除的所有行,然后提交表单。

What I want to do, is have an alert when the delete button is pressed, that asks for confirmation before deleting. 我想做的是,当按下删除按钮时发出警报,要求在删除之前进行确认。 What I would like to do, is to list out all the rows that were marked for deletion in this alert window. 我想做的是列出在此警报窗口中标记为删除的所有行。

I'm not sure if this is possible, as the POST data isnt available until the form is submitted, which in turn would be prevented by the alert window. 我不确定这是否可行,因为POST数据在提交表单之前是不可用的,而警报窗口会阻止它。

Would this be possible using PHP and javascript? 使用PHP和javascript是否可能? I have included some code examples below: 我在下面提供了一些代码示例:

<form name="manage" method="post" action="edit.php">
    <input type="submit" name="add" value="Add">
    <input type="submit" name="edit" value="Edit">
    <input type="submit" name="delete" value="Delete">

//For each row found
while($row = mysql_fetch_assoc($result)) {
    //Echo out a row with details
    echo "<tr>
        <td><input type='checkbox' name='dirid[]' value='".$row['Dir ID']."' /></td>
        <td>".$row['Floor']."</td>
        <td>".$row['First Name']."</td>
        <td>".$row['Last Name']."</td>
        <td>".$row['Extension']."</td>
        <td>".$row['Department']."</td>
        </tr>";
}
</form>

At the moment, all that is posted, is the dirid, which is just a unique ID for each row in the table. 目前,所有已发布的内容都是分散的,它只是表中每一行的唯一ID。 The delete script then queries the database, and removes each row for each of those ID's 然后,删除脚本会查询数据库,并删除每个ID的每一行

I suppose that if it is not possible in an alert window, I could also send the ID's to the delete script, show them on the page with a confirm button, and then put and alert on top of that as well, but seems a bit long winded. 我想,如果在警报窗口中无法实现,我也可以将ID发送到删除脚本,并在页面上使用确认按钮显示它们,然后再在其上放置并发出警报,但似乎有点wind。

Any suggestion greatly appreciated. 任何建议,不胜感激。

Eds 埃兹

也许可以在这里使用jquery来实现,例如http://jsfiddle.net/damian_silvera/Cxqp5/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM