SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,033
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How do I get php variable to display in form Textarea?

    Hello all,

    I am trying to fill the content of a "form textarea" box with content form MySQL but it is not working.
    That is the textarea does not display anything!
    Other form fields I am able to fill without any problems. Also using echo I have checked to make sure that variable $body is properly loaded.
    What do I need to do to get this to work?

    In case here is the HTML & PHP code:

    Code HTML4Strict:
                    <tr bgcolor="#c6cedf"> 
                            <td colspan="3"> <b>Body of this article</b>
    						<br>
    						<br>
                              <div align="left"> 
                                <textarea name="body"  cols="60" rows="5" wrap="VIRTUAL" id="comms" value="<?php if (isset($body)) {echo $body;} ?>"
    				  onKeyDown="textCounter_rem(<?php echo $counter; ?>)"  onKeyUp="textCounter_done(<?php echo $counter; ?>)"></textarea>
                              </div>
                            </td>
                          </tr>


    Thank you before hand for your help.

    Regards,

    Anoox search engine volunteer

    www.anoox.com

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,836
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Code:
    <textarea name="body"  cols="60" rows="5" 
    wrap="VIRTUAL" id="comms" 
    onkeydown="textCounter_rem(<?php echo $counter; ?>)" 
    onkeyup="textCounter_done(<?php echo $counter; ?>)">
    <?php if (isset($body)) {echo $body;} ?>
    </textarea>
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As Stephen has demonstrated, textareas don't have a value attribute. Their value is between the opening and closing tags. Any thing in side the beginning and ending tags including white space from a line return in the source will show as content.

  4. #4
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,033
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the tip.
    It works fine now

    Have a great day.

    Quote Originally Posted by felgall View Post
    Code:
    <textarea name="body"  cols="60" rows="5" 
    wrap="VIRTUAL" id="comms" 
    onkeydown="textCounter_rem(<?php echo $counter; ?>)" 
    onkeyup="textCounter_done(<?php echo $counter; ?>)">
    <?php if (isset($body)) {echo $body;} ?>
    </textarea>

    Anoox search engine volunteer

    www.anoox.com

  5. #5
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,033
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks I corrected the problem as per the advise.

    have a great day

    Quote Originally Posted by Hammer65 View Post
    As Stephen has demonstrated, textareas don't have a value attribute. Their value is between the opening and closing tags. Any thing in side the beginning and ending tags including white space from a line return in the source will show as content.

    Anoox search engine volunteer

    www.anoox.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •