Nach Bildung

“Die arbeitenenden Klassen streben nach Bildung, weil sie sie für ihren Sieg brauchen”

Labour and knowledge is a source of success in every profession. If you have no talent, then—learn, read, study, practice and work as much as you are able. It really helps to succeed.

Wednesday, 4 September 2013

Google forms changed. How to update the code used before?


In my many site templates I used Google forms instead of custom php forms. Google forms are very comfortable and organized way of collecting emails sorted by topic or audience. I used to take default code provided by Google, change it slightly, style it pretty and inject into sites. Now Google change a little bit its code and many users of my templates are stuck. In fact it is very easy to make it working again. Below I described those steps which are required to get your Google form agin working and well-styled.

Start doing

First of all create default form in Google Drive. Once you defined all fields and saved it, view it online. You see working working form which is fine apart two things: it is not well-styled and it is not in your website. So, you need to do next thing: right click–view source. What you see is a bunch of scaring html code. Do not get scared. You do not need to read it or understand in general. What you need now is to open my html snippet which always comes with my templates. Open it in your html editor. What you see is much better brushed up and organized which usually looks this way:


Well, it also looks pretty big but this is unavoidable and in fact you need to spot just a few things, to be more precise, you need to take a look at form action link and id/class/name for input. Hence, compare how is written form action link in default Google form and in mine one. This is mine:


This is default:


In my code you may delete all above the tag "form" (i.e. script and iframe) keeping it like this:


Now replace form action link with the one you got with the default code generated by Google and this part is over. Your updated line of code should look this way:


Pay attention on the fact that you do not use ol tag anymore and you changed onsubmit from "submitted-true" to empty value.

Next thing to do is to just replace ids and names. In my code per every input you see values like entry_1 or entry.1.single. In new Google forms each value has multi numbered id consisting of 10 digits and looking like this one: entry_1428468947. So, all left to do is to replace these values. If in my code you see it this way:


now it should look this way:


where label name, id and class has multi-digit number generated individually for each unique Google form.

That's it. Go through each input and insert your 10-digits number for name, id and class. Save. Your form is now updated and in working condition. Like before, if you set up notification to receive emails to your email inbox in Google Drive setting you will keep continue emails in same way and all emails will be stored in your spreadsheet as it has been before.


Post a Comment