Reputation: 23141
let's assume there is a site http:/ /testsite.com
, with some filds and submit button.
Is there a way, to write a javascript script, which will fill all filds with values i want, and make submit operation automaticaly?
Is it possible, maybe there is some documentation about it?
Thanks
i don't have access to the script of site, i must make it from another server.
Upvotes: 1
Views: 2130
Reputation: 6782
Maybe you're looking for something like Selenium, which can record your actions (using a browser plugin), save them as test scripts, and replay them later.
Another option would be to craft a custom POST request using CURL, or create your own form that submits to the page that handles the form on testsite.com
.
It really depends on what you're trying to accomplish.
Upvotes: 1
Reputation: 7997
Do you mean a site that is not your own? Like, you want to embed another site's form into your webpage and then auto-fill some values? No, generally speaking this cannot be done because of the same-origin policy. The best you could do is proxy for that site, e.g. your web server can fetch the form, fill out values and present that to your users. This won't work (or, not very well) if the other site requires authentication.
Upvotes: 2
Reputation: 163248
Sure, try this:
$('form').filter('input').each(function() {
$(this).val('Some value');
}).end().submit();
Upvotes: 1