简体   繁体   English

警报将根据我所拥有的表格数量弹出

[英]alert will pop up accordimg to the number of forms i have

So I crated a Mad Libs game, and I wanted an alert to pop up when I don't enter anything in the forms, so they know that they need to fill in the blanks to proceed. 因此,我创建了一个Mad Libs游戏,我希望在我不输入任何表单内容时弹出警报,以便他们知道他们需要填写空白才能继续进行。

现在的代码看起来像这样

The popup all comes up at the same time depending on how many forms there are so lets say there are 5 forms, then the pop up will come up 5 times. 弹出窗口全部同时出现,具体取决于有多少种表格,因此,假设有5种表格,那么弹出窗口将出现5次。 How would I fix this? 我该如何解决? Thanks in advance. 提前致谢。

You have a "confirm()" statement within a for loop. 您在for循环中有一个“ confirm()”语句。 Every time the for loop iterates, the confirm statement produces a pop up. 每次for循环迭代时,confirm语句都会弹出。

remove the alert code from the loop and instead just check if there are blank forms in the loop and if you find one set a value in a var. 从循环中删除警报代码,而是仅检查循环中是否存在空白表格,以及是否在var中找到一组值。 At the end of the loop if the var indicates you found an empty form.. show the alert then. 在循环结束时,如果var指示您找到了一个空表格,则显示警报。

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

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