How to take text from another page and insert it into an input?

Asked

Viewed 924 times

-4

I have a small doubt in a project I’m developing.

The following happens:

I have this input on a page (index php.):

<input id="exibe" value="Aqui vai ficar o texto **que foi** copiado">

On the other page, I have this element (wow.php):

<font id="pegar" class="campo">Aqui fica o texto **que vai ser** copiado</font>

What I need is that when the person accesses the index php. who owns the input with id="exibe", that input will have his value="" filled in with the text on the other page (wow.php) that is inside the <font> with id="pegar".

It is possible to do this?

  • It will be the text that is inside the <font>, in the case of "Here is the text that will be copied" :)

  • It is already generated. It is a page already made. What I want is to remove this doubt that I have been trying to find out for years. Kkkkkkkkk :)

  • 1

    Your question is how to get HTML text?

  • Simmm :D Exactly!!!

  • 1

    Already answered on the site then: http://answall.com/questions/78621/70

  • But it has to be set to input value="".

  • It pulls a text that is on another page, and plays that text within the value of the input, on the home page.

  • 1

    Exact, question with several different subjects ends up being too wide. And both already have answer on the site, just give a little search. Anyway, the tricky part is what I pointed out in the link above. the rest is just one echo in the value, that solves (do not forget to escape the special characters).

  • Something so simple? Look at the size of the question!

  • Thank you very much @Bacco was just what I wanted!!! I just made it work here :)

  • 1

    only do not forget about htmlentities() in value echo, otherwise you may have problems with special characters.

Show 6 more comments

2 answers

1

Alexander, the simplest way to do it is as follows:

index php.:

<html>
<body>  
    <form id="form1" method="post" action="puxa.php" >
        <input id="pegar" name="pegar" class="campo" value="Aqui fica o texto **que vai ser** copiado"/>
        <input type="submit" value="enviar" />
    </form>     
</body>

wow.php:

<html>
<body>  
    <input id="exibe" value="<?=$_POST['pegar']; ?>">  
</body>
</html>    
  • Friend, are you sure you tested this code? Kkkkkk

  • I’m sure. Any problems with compiling? Maybe your php is not configured correctly. Which error you found?

-1

Yes. send the value of the page through an ajax request or make a post. You can save this value to a Session object. In php it would be: $Session['name_session'] = 'value sent';

on the other page it would be necessary only to call the value: echo $Session['name_session'];

  • Could you edit your answer? It got very confusing, rsrs

Browser other questions tagged

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