How to display a customized webpage using Google Web App? - google-apps-script

I'm trying to write a web app, such that when a user fetch his/her username to the web app, the web app will retrieve the data stored previously in a Google Sheet, and construct a form (webpage) based on the username. What I mean is, each username will have different contents to work with.
The problem is, I just cannot get the page to display; it just shows up for a second, and a warning sign just appears, and this makes my webpage looks so suspicious, while in fact, it isn't.
Here's the part of the code to show up the webpage:
The code above checks if it's the first time the user comes to the page, so a welcome page should be loaded, then he/she can continue from there.
And here's the page after a blink of an eyes:
What I want to ask is, is there a way that I can load a page based on the username given? I don't really know what I am doing wrong. :<
Thank you guys so much in advance.

Related

What is the correct way to change html dynamically using django

Suppose we have a login page where, in the first stage, we are asked to enter our email. We send this information to the server, which searches whether there is an account with this email, and if there is, our goal is to change the state of the page, to a page where the user is asked to enter the password for this account. If, on the other hand, there is no account with that email, the state of the page changes to one where the user signs up. And let's say that, for the sake of aesthetics, all this happens using the same url.
My question is, what is the correct way to inform the client's page to what stage to go into?
Sending the whole html code is an option, but this seems like it will put too much pressure on the server. Is there a cleaner way, that we can send less information, and still be able to have the same result?
I am new to django and web dev so please explain thoroughly.
For a browser engine submitting a form with email is a new page request and a new rendering of HTML after that. The source of new HTML code is your server with Django, so you should generate a new HTML with a relevant template and send it as a response.
Such user provoked events change a state of your application for a given user session, not a page.
For speed you can use caches for styles, for menus, for HTML snippets (headers and footers).
Also you can make a one-page application, but you must use JavaScript framework for it. Then your JavaScript code executing in client's browser can request concise JSON with necessary information instead of full HTML.
Then your JavaScript framework is responsible for a correct insert new dynamic HTML elements in the current document object model (DOM).

Display custom message after submitting a Google Form

I have a Google Form that allows user to enter their information. After they submit the form, the data is inserted to a Google spreadsheet as a new row.
However I want to show a dynamic message right after the form is submitted, overriding the original "thank you" message. The new message would display the information they just filled in, with an number assigned to him.
For example, Mary filled in her data and submit the form. Since Mary is the 5th person to submit this form, the message shows her number as 5.
Is there any way to achieve this? I have been studying Google App Script and HTML service but I am not sure if this is the correct way.
Please note that we have already using email to send out this message for several years however user strongly suggest that showing their ID right after form submission would make lots of things much easier.
Thank you very much!
Update
I have been working on it and now I am able to make a web page that inserts a new row to a spreadsheet. But another question: How to publish the web page? When I open the "/dev" link it works fine; However when I open the "/exec" link it says cannot find "Index.html" and I am sure there is a file called Index.html.
There is no way to add a custom confirmation message for the current user of the currently open Form. You can run code to change the confirmation message when the Form is submitted, but changing the confirmation message when the Form is submitted won't take affect until the NEXT Form is opened, and that's too late. So the next person to open the Form would get the confirmation message of the previous user.
You would need to convert everything to a stand alone HTML App for something like that.
Google just released a new version of Google Forms. In the settings you can change the confirmation page message for respondents. You can save a link to a web page in the custom message. So if you can create a web page with the data you want displayed, you should be able to save the link in the custom message.
In order to achieve the above-mentioned goal, you need to get the Google form on your web page. No, I am not talking about embedding the form to your web page but to create a stand alone HTML page. The reason behind doing so is since Google is a third party website, editing any code in Google forms is not possible and there is no other way (at least I could not figure out Yet) to place custom thank you page URL for the Google Form. You can even remove certain codes in your HTML page to make sure it doesn't look like or says Google form. Basically, to have custom URL you need to replace
Code to be replaced for custom Thank you url in Google form
In case you are not a techie, Playing with codes might break the code.This step by step blog for customising Google form might help you.

saving form data in html

I only know CSS and HTML. I have to create a web page with an account opening form. My faculty had told me to make it at that so I built it. He asked me not to host it.
Now he is asking me to take everyone response and create a database. I could do that by sending the webpage to everyone and asking them to download the page locally in their system and then open and fill the form. But I do not know how to save that data. If I could get the output in a text file it will be time saving, but even if the page retains the information while my classmates send it back to me it will be great. Can anyone help me on how to save the data?
I know creating a word file would have been much easier but he wanted web page so I am stuck.
You cannot do this with only HTML and CSS. To do this, you would have to code a server-sided page so that you can serve HTML pages to your users, as well as receive data back from them.

adding context information to the URL

I need to add context or the current state of my website to the URL of the page.. So that if a user copies and sends the URL to another user. The other user can see the exact state of the website that the sender was watching, i.e. the tab he was in,and the data he was viewing. I have seen similar things being implemented in other websites like facebook, gmail, etc but I don't know how to do that in my application. How should I approach this problem?
Use pushState and friends to modify the URL to one which your server can use to deliver a page that starts in the desired state.

an iframe for multiple users

I am trying to create a web page with the following :
Buttons and input fields etc. in the top half of the page that allow the user to define certain criteria, when the user clicks submit, the page calls some php code that writes an iframe referenced html file which is then shewn on the bottom part of the web page.
I think I understand how to do this for a web page referring to a single iframe document source but there may be more than one user running the page so how do I have the iframe pointing to the correct iframe source for each user?
Some web searching sugests that this is the kind of thing done with XMLHttpRequest, I'll have a look into that.
If I understand correctly, your PHP code creates an HTML file and then loads it in an iframe.
You could have your PHP script output the HTML, then load the PHP script in your iframe directly. Now there is no way for another user to accidentally get the other users' output.
I'm not sure if I understand exactly what you want to do.. but if you have already existing database of users, make a new table with Iframe preferences... so when they click submit, the preferences will be saved to the database with the user_id.. so next time just check if the user has already chosen... if yes, get the preferences from database.. if not -> redirect him to do so.
I don't know if that's exactly what you want