How to set a value in an input tag of another site?

Asked

Viewed 1,027 times

1

How could I pass a value to a field <input> from another site?

In practice, I would like when the user clicked on a link, button, etc. to open another page of any site (e.g. www.google.com) and in a certain field appear a value I have on my site.

Thus it would be necessary only for the user to submit the form on that other site.

I use PHP, Javascript and Jquery technologies.

  • If the "other site" is not of your own, how will you manipulate its behavior to get information and apply the same where you want? In a search engine like Google, still resolve, but on other sites... difficult.

  • You can explain that is the other site and if it accepts CORS?

4 answers

2

1

The fields of a form are usually pre-filled by the attribute value="". Simply by calling another site, there is no way you can modify this attribute to by any data.

Sometimes, as @Matheuscristian mentioned, the site is done that can pass some value through the URL, and there that site places that value within the attribute value.

Thus, it is at the mercy of the implementation of the other site, and has nothing guaranteed.

0

da p/ run a javascript script to fill whatever you want, but however, the script will run and fill only the browser where the script runs, ie if you want to do this to "force" a schedule to the site will not scroll, but if you want to write a "layer" javascript after browser page open dai yes is possible, just open the console,paste the script and run it.

0

You can use the GET example method:

$x = $_GET['id'] ? $_GET['id'] : NULL;

and in html:

<input type="text" value="<?= $x ?>"/>

in site1 you can do to redirect to site2 example:

<?php header('Location: www.site2.com/index.php?id='. $id); ?>

and the value of x will be the value of $id

Browser other questions tagged

You are not signed in. Login or sign up in order to post.