Reputation: 205
I have two issues:-
1. I need to be able to set the value of a textarea
2. I need to then get the value of the text area again for updating. I see that text area does not have a 'value' tag or something.. so I am not sure how to do this via PHP. I tried something like
print("<textarea cols='15' rows='2' name='textdesc'>$info_desc</textarea>");
to set it. But no luck and then i will have the same problem when retrieving.
Upvotes: 1
Views: 17602
Reputation: 1
$info_desc
is actually value of your textarea.
If you submit it, you will get the same value for $_REQUEST['textdesc']
.
Upvotes: 0
Reputation: 17
Mayby your variable are undefind?
I try this code and it works correct.
$info_desc = "12345";
print("<textarea cols='15' rows='2' name='textdesc'>$info_desc</textarea>");
Upvotes: 2
Reputation: 164742
To set the value in HTML...
<textarea cols="15" rows="2" name="textdesc"><?php echo htmlspecialchars(
$info_desc, ENT_QUOTES, 'UTF-8') ?></textarea>
To retrieve it (assuming your form issues a POST
request)...
if (isset($_POST['textdesc'])) {
$textdesc = $_POST['textdesc'];
}
Upvotes: 4