Robert de Klerk
Robert de Klerk

Reputation: 624

Set text in textarea with PHP

How can I set the text of a textarea object in PHP, is it necessary to use javascript.

I want to have one textarea, and be able to set the text that is displayed at different times.

Thanks

Upvotes: 1

Views: 32512

Answers (3)

yasin
yasin

Reputation: 269

  <td>
    <textarea rows="4" cols="10">
      <?php 
      echo $row['baddress'] ;
      ?>
    </textarea>
  </td>

  <?php 
  echo $row['baddress'];
  ?>

It must be call separately here baddress is the column name of my data base

Upvotes: 0

Peter Ajtai
Peter Ajtai

Reputation: 57685

<textarea rows="2" cols="20">
<?php echo "Your text here. This can be dynamically created with PHP
when the page is served."; ?>
</textarea>

So, the textarea can be filled with PHP, but if you want to change the textarea after the page has loaded.... once it's out of the hands of the server, then you have to use Javascript.

Upvotes: 8

Ian Henry
Ian Henry

Reputation: 22403

If you want to change the text after it has been downloaded by the client (for example, have the text change every five seconds or something), you must use javascript. PHP is only used for server-side generation of the markup that the client downloads.

Upvotes: 0

Related Questions