javascript - How do I create a pop up box in Google App script? -


Basically this is my question:

How do I use the Google app script w / HTML service Do a pop up or dialog box.

I'm verifying a lot in a Google Script file (as is an app for HTML file) and I should just tell the error to the user, then they can adjust their form and proceed. ... this has been my verification so far. I tried to use the JavaScript Alert () function, but it does nothing.

  if (date == "") {alert ("please select date"); } And if (Teacher == "") {Warning ("Please give your name"); } And if (group == "") {warnings ("Please enter a group"); } And if (Notes == "") {Warning ("Please note the technique where the technique is being used"); } And if (events.length! = 0) {window.alert ("It appears that the attempted slot of your book is taken"); } Else {I hope that I can do this recognition in such a way and it is not a whole new method of verification (most likely from within the HTML file).   

If your validation script (if elseif statement) is in the Code.gs file, then the alert function will not work.

What you want to do is throw away your html.script.run function in your html script by using .withSuccessHandler, then warn from there.
Since the warning is called within the HTML (not in the .gs file), it will work.

Assume that the script above is in a function called a valid firm () and you are calling it on your submit form button, you will see the code like this: < P> HTML file

  // Here are some code and scripts Google.script.run.withSuccessHandler (showAlert) .validateForm (this.form); Function Show Alert (Stringfram Codgs) {if (stringFromCodeGs! = False) {Warning (stringFromCodeGs); }  

validate the GS file

  function (form object) {if (formObject.date == "") {return "Please select a date" ; } And if (formObject.teacher == "") {return "Please give your name"; } // your second and if here} and {// your code here returns false to act on the form; }  

What does it do that throws back the error message to your google.script.run, which will then use it as a parameter for the success operator - in this example , The ShowAlert () function, is automatically called by .withSuccessHandler ().

Hope it helps


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -