views:

73

answers:

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

A: 

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
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