1

I'm working with a script that is scraping data from my currently viewed page correctly. Now I need to know the syntax that lets me inject (and submit) those values into a form found on a different page.

code for the bookmarklet:

javascript:var%20s=document.createElement('script');s.setAttribute('src',%20'http://jquery.com/src/jquery-latest.js');document.getElementsByTagName('body')[0].appendChild(s);void(s);var%20s=document.createElement('script');s.setAttribute('src',%20'http://juststeve.com/test.js');document.getElementsByTagName('body')[0].appendChild(s);void(s);

can run against: http://juststeve.com/testData.htm needs to inject it to the form: http://juststeve.com/testform.htm

thankx

justSteve
  • 5,444
  • 19
  • 72
  • 137
  • Sorry...the ajax that had been in test.js should have been commented out. Having been able [EDIT - should have typed: '_unable'] to work directly against the GoogleDocs server I'd like to shift attention to injecting the form at juststeve.com/testForm.htm and submitting that. – justSteve Jan 25 '10 at 15:28
  • @justSteve... your comment could be edited into the question, and would make it much clearer. – Mogsdad Aug 29 '13 at 02:01

2 Answers2

3

You might want to take a look at: scripting a google docs form submission

Community
  • 1
  • 1
Dvir Berebi
  • 1,406
  • 14
  • 25
0

Since you seem to be using jQuery to perform the data harvesting and submission, you should first check the jQuery documentation. There you'll find how to use $.ajax to submit data (using the data parameter).

In short, what you have to do is replace

data: { formkey: "Fd0SHgwQ3YwSFd5UHZpM1QxMlNOdlE6MA", entry_0: "this"  },

with

data: { formkey: "Fd0SHgwQ3YwSFd5UHZpM1QxMlNOdlE6MA", entry_0: "this", "orderDate": orderDate, "email": email, "customerID": customerID },

meaning that the AJAX POST request will give the server 3 extra parameters in the request with the values I'm guessing you want to submit. How you deal with retrieving such values in the server side will depend on the server side language/stack you're using.

Miguel Ventura
  • 10,344
  • 2
  • 31
  • 41
  • Thankx...the argument list is kind of secondary at this point. Working with the form directly you'll notice that it'll submit correctly with no field contents at all ... plus the bookmarklet's ajax is responding with the 'success' handler but the form is not being submitted. – justSteve Jan 25 '10 at 15:26