I have a Rails app that displays a Googe Form in a Bootstrap modal.
Here is a picture of the browser:
I would like to add a default to the name input field.
This is the coffeescript code - that doesn't work:
$(document).ready ->
$("#gformshow2").click ->
alert "hi"
document.getElementById("entry_252495961").value="david"
return
The "hi" alert displays just before the modal is opened.
The reason is the form is in an iframe which you have no access to. The coffeescript code gets executed on your page, not the Google form.
As far as I know it is not possible for you to modify the content of that Google Form (think of the security implications… it would mean that you could fill it out for them, even submitting it without their consent)
https://www.bettercloud.com/monitor/the-academy/set-pre-filled-responses-in-google-forms/
To set a pre-filled response in Google Forms:
Create a Google Form like you normally would
Click the ‘Responses’ section in the toolbar
Click ‘Get pre-filled URL’
Fill out any fields you would like pre-filled and click submit
Copy the new URL at the top of your screen and share that, rather than the conventional URL
Related
I have a simple Lotus Notes XPage with only an editable RichText dialog that is embedded in a bigger form using an iframe.
The bigger form has a submit button, which triggers some javascript and finally a notes agent which saves all non-richtext values that are inside the bigger form.
Of course the user shall not have to use two submit buttons, so I won't have a (visible) submit button for the XPage. Instead, I want to use javascript to tell the iframe to submit the form.
Using iframe.document.forms[0].submit() does not work - the form is indeed submitted to the Notes server, but XPages won't save the changes I made.
Using a simple XPage button with the action "Save Data Sources", saving works like a charm, but I don't want the user to have to click two buttons in the correct order.
I also tried the following javascript code to fill some invisible fields with the values that IBM submits to the server, but this does not help either:
iframe.document.forms[0].elements["view:_id1:inputRichText1_h"].value = iframe.document.forms[0].elements["view:_id1:inputRichText1"].value;
iframe.document.forms[0].elements["view:_id1:inputRichText1_mod"].value = true;
iframe.document.forms[0].elements["$$xspsubmitid"].value="view:_id1:_id4";
iframe.document.forms[0].elements["$$xspsubmitscroll"].value="0|0";
iframe.document.forms[0].submit();
So now I ask you: how to correctly submit that form content, without the user actually clicking the XPages button? Can I programmatically trigger a click on that button, which would be indifferent from a human actually clicking, except for the human?
have an ordinary div with a fixed id and inside this div have a computedtext that will compute the clientsideid of the "save button" and return that inside the div
and use this clientside js code to do the actual click
var id=iframe.document.getElementById("button").innerHTML
var button=iframe.document.getElementById(id)
button.click()
So I'm pasting in some code for a form from Salesforce.
This code to be specific: (from the style element to the end of the form) https://gist.github.com/13ab0efd07c2c8cdb3e1
When clicking submit while not filling out any or all fields, I get a form validation check and then a message will popup with the fields that I have not filled out.
However, when I paste the code into our LightCMS template the form validation is not working and just redirects to the thankyou page as if everything went through fine.
They use LightCMS. And even when link to an external js file instead of embedding the js I still get the same results.
I've noticed it adds an "onclick" element on the Submit button on the front-end but it only does that when it's in the CMS not on a bare bones HTML page.
Any thoughts?
i think you should add this
onsubmit=return formvalidator(Document.getElementByid(search-form))
before form action because it will check the form before submitting it. if check fails the action will not occur.
I want to create a bookmarklet that will allow users to submit URLS from sites on the fly as they browse.
I'm looking for three possible implementations of this bookmarklet.
Simply click the bookmarklet and be taken to the page with my form field and have the URL they just came from entered into the field.
Simply click the bookmarklet and be taken to the page with my form field and the link they had highlighted from the previous page is entered into the field.
The preferred option - Click the bookmarklet, a popup (similar to Twitter's tweet box in size and function) opens with my form field pre-populated with the URL of the page they clicked the bookmarklet on. Like Twitter's tweet box and facebook's share box.
I typically don't just give away code, but this is so simple I figure it's worth sharing and explaining.
Compressed:
javascript:(function(f,s,n,o){window.open(f+encodeURICompnent(s),n,o)}('http://example.com?url=',window.location,'yourform','width=300,height=200'));
Expanded
(function (formurl, site, name, options) {
window.open(
formurl+encodeURIComponent(site),
name,
options
);
}('http://example.com?url=', window.location, 'yourform', 'width=300,height=200'));
The way this works is it just calls an anonymous closure to pass variables to the window.open function. It passes the current page's location as the uri value in the query string.
On the page containing your form, you'll need to populate the correct field with the value from the query string.
Although this could be written without using a closure, you need to make sure that there isn't a return value from whatever's being called, as javascript:<string value> will re-write the DOM with whatever text was in <string value>.
I see this pattern used very often!
Click on a link
popup appears with a form
fill in form and submit
popup closes and main page populates itself with the form's data.
Any idea how this works?
Edit:
by popup I mean an actual window popup, rather than a modal window. A modal window could work nicely though I reckon.
Do you want something like this ?
http://jqueryui.com/demos/dialog/#modal-form
http://jqueryui.com/demos/dialog/modal-form.html
You can validate the form with js / jquery and then do an ajax call and post the data to the server
The only way to do this is with Javascript. Django's own admin includes a (fairly clunky) example: when you save the popup, it returns a response consisting of just a <script> tag containing Javascript which references the box in the parent form. See for example django.contrib.admin.options.ModelAdmin.response_add.
You can use somethign like facebox to create the popup. This requests a page to the server (your form). Once submitted, detect that the facebox was closed (see the API) and make a new ajax request to the server that will return the needed data to populate your page.
A client sent me a form template they had created using https://jotform.com to implement on their WordPress site. The form template is supposed to hide part of the form until the user clicks the next button. At which point a script is supposed to validate all of the input fields the user has presumably filled out and then display the rest of the form. While I have successfully managed to get the form to display the next part of the form when the user clicks next, it fails to validate the input fields.
It's kind of difficult to explain without a huge block of text so it is probably easier to show you:
The original working template that the customer sent me:
http://www.loftist.com/jotform/List_Your_Loft.html
The problem child:
http://www.loftist.com/?page_id=78
If you just click on one of the input fields and then click elsewhere on the page, the input fields successfully return a validation error message and prevent the user from clicking on the next button. However, if you simply click on the next button than the next set of fields get displayed.
Any thoughts? What am I doing wrong here? Im convinced this must be a really simple problem but Im not sure what it could be.
I don't understand the problem. Your first link, the original template, works for me with all the validations in place. The problem child on the second link is not a jotform form, and it doesn't have any paging stuff.
Do you mean jotform on your first web page is not working correctly? What does this have to do with the second form on your second link?