简体   繁体   English

onSubmit在表单上不起作用

[英]onSubmit doesn't work on the form

I'm making a page that retrieves coordinates from a database and shows them as markers on google maps. 我正在制作一个页面,该页面从数据库中检索坐标并将其显示为Google地图上的标记。 I have a submit button that lets you delete a selected marker. 我有一个提交按钮,可让您删除选定的标记。 What I'm trying to do is add a warning before deleting, but it unfortunately doesn't work. 我正在尝试做的是在删除之前添加警告,但不幸的是它不起作用。 I've tried with onSubmit and with onClick (which is probably wrong anyway). 我已经尝试过onSubmit和onClick(无论如何可能都是错误的)。 I've been searching for hours but nothing seems to work. 我一直在寻找时间,但似乎没有任何作用。 I don't think the rest of the code is important, but I'll post it if needed. 我认为其余的代码并不重要,但是如果需要,我会发布它。 Any ideas? 有任何想法吗? Here's the code of the form: 这是表格的代码:

echo '<form align="center" onSubmit="return confirm("Are you sure?")" class = "delete" id="delete_form" name = "marker_list2" action="delete_marker.php" method="post">';
            echo '<input type="submit" value="Delete" name="edit">';
        echo '</form>';

Looks like you've got conflicting double-quotes. 看起来您的双引号引起了冲突。 Try replacing 尝试更换

onSubmit="return confirm("Are you sure?")"

with

onSubmit="return confirm(\'Are you sure?\')"

Make sure to escape the single quotes, because it is inside your PHP echo '...' 确保转义单引号,因为它在您的PHP echo '...'

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

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