1

Ok, I may have found enough information that I should be able to put this together myself, but I just can't.

I'm trying (because reasons) to get string input from users by calling something like this:

var myVar = prompt("Some question?");

I want the prompt popup to automatically submit after, say, 30 seconds. Then I want the script to keep running. I want to use prompt because it's easy. Is there a way to auto submit that based on a timer?

I feel like the key might be somewhere in these two links: http://www.w3schools.com/js/js_timing.asp Click a button every second

Do I need to use a popup, not a prompt? Javascript popups: Submit form, show "wait" screen for 5 seconds, then auto-close popup

Or do I need to use a form? Auto-Submit Form using JavaScript

Thanks in advance for the help. New user here, and I don't think this question has been answered before.

Community
  • 1
  • 1

2 Answers2

1

Ok, so here's my answer:

  1. Use jQuery
  2. Use Alertify
  3. Use setTimeout

These three things got me where I needed to be; hopefully someone else will eventually stumble on this and get some use out of it.

0

If you want any kind of control over the behaviour of your prompt, besides just a means of basic text input, you will want to create your own prompt within a popup window or lightbox. The built-in prompt does not have any kind of auto submit functionality. It will not work in certain versions of Metro IE and has varying behaviour across different browsers (Safari).

https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt

Alex W
  • 37,233
  • 13
  • 109
  • 109