Computer Science Canada Populating Text Box with PHP |
Author: | Phenomena [ Sun Mar 11, 2007 12:58 am ] |
Post subject: | Populating Text Box with PHP |
Ok I'm fairly new to php and would really like to learn it ![]() ![]() |
Author: | morgaine [ Sun Mar 11, 2007 2:52 am ] |
Post subject: | RE:Populating Text Box with PHP |
for appending the value of one text box to another, you really don't need a server-side language, JavaScript is the easiest way to go. That said, here's what you can do in php: (copy and paste the following into a file called sample.php to test it out) <html> <body> <?php $_GET['list'].=($_GET['list']=='' ? $_GET['name']:"\n".$_GET['name']) ?> <form action="sample.php" method="get"> Name: <input type='text' name='name' /> <input type='submit' value='submit' /><br /> <textarea name='list'> <?php echo $_GET['list'] ?> </textarea> </form> </body> </html> |
Author: | samara [ Tue Jun 02, 2009 11:16 am ] |
Post subject: | Re: RE:Populating Text Box with PHP |
morgaine @ Sun Mar 11, 2007 2:52 am wrote: for appending the value of one text box to another, you really don't need a server-side language, JavaScript is the easiest way to go.
That said, here's what you can do in php: (copy and paste the following into a file called sample.php to test it out) <html> <body> <?php $_GET['list'].=($_GET['list']=='' ? $_GET['name']:"\n".$_GET['name']) ?> <form action="sample.php" method="get"> Name: <input type='text' name='name' /> <input type='submit' value='submit' /><br /> <textarea name='list'> <?php echo $_GET['list'] ?> </textarea> </form> </body> </html> Hello Morgaine this code was very helpful for me!! but when i am opening the sample.php over the web, i am getting 3 errors: 1,) at line 3 (<?php $_GET['list'].=($_GET['list']=='' ? $_GET['name']:"\n".$_GET['name']) ?> ) "Undefined Index List on line 3" 2.) Undefined index name on line 3 3.) undefined index list on line 3 what should i do? |