Re: PHP inside Javascript
| From: | Lars Torben Wilson | Date: | Tue, 12 Sep 2000 06:46:21 +0000 |
| Subject: | Re: PHP inside Javascript | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-16281@lists.php.net to get a copy of this message | ||
Ron Newman writes:
> At 11:26 AM 9/5/00 -0700, you wrote:
> It's been a while, I've been off on other things, and now back to this. Is
> this what I meant? Sortof. But:
> What's the best way to "re-fill the form inputs" without using javascript,
> before presenting the form page again?
> - print a META tag with refresh
> - header(Location:...)
> I'm not aware that either of these know anything about forms. I use META
> refresh in another place to propagate form data, but that's in conjunction
> with an HTML tab:
> <BODY onLoad="javasubmitfunction()">
> in which case we're back to Javascript, the very thing I'm trying to avoid.
>
> Hmmm.
You can preset a form <input> by printing a variable into its value
attribute:
<form action="<?php echo $PHP_SELF ?>" method="post">
<input type="text" name="username" value="<?php echo $username
?>">
<!-- For a <textarea>, you'd do it like this: -->
<textarea name="foo">
<?php echo $foo ?>
</textarea>
<input type="submit">
</form>
You'll probably want to trim() the $foo from that last one, actually...:)
But that shows the basic idea...
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+