php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44768 getAttribute can't find textarea value
Submitted: 2008-04-17 22:51 UTC Modified: 2008-04-18 11:59 UTC
From: sathia dot musso at gmail dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.2.5 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sathia dot musso at gmail dot com
New email:
PHP Version: OS:

 

 [2008-04-17 22:51 UTC] sathia dot musso at gmail dot com
Description:
------------
I know there's no such attribute value="" but you can't access the content ($textarea->textContent will not work as well) of that if the content inside is wrapped within "lt" and "gt" <textarea><won't read></textarea> (ie when you read embed tags from textarea)

Reproduce code:
---------------
$documentx = new DOMDocument();
$documentx->loadHTML($data);
$textareas = $documentx->getElementsByTagName("textarea");
foreach($textareas AS $textarea){
   print($textarea->getAttribute("value"));
}




<textarea><img src="foobar" /></textarea>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-18 04:42 UTC] chregu@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

If there's no attribute "value" then there's nothing to print then 
there's no output.

  print $textarea->nodeName;

instead of

  print $textarea->getAttribute("value");

does produced some expected thing.
 [2008-04-18 11:55 UTC] sathia dot musso at gmail dot com
I can't understand what "expected thing" should be.
I agree that the dom parser sees the textarea,
but if the textarea content is wrapped within < and > there is no way to read its content.

<textarea><img src="foobar" /></textarea>

In javascript if you set the value of a textarea to be "xxx" it's filled correctly even if the attribute value does not exists in the textarea tag


thank you for your time
 [2008-04-18 11:59 UTC] sathia dot musso at gmail dot com
this should help to understand, in Javascript you can access this strange attribute

<textarea id="pippo"></textarea>

<script>
document.getElementById('pippo').value = "<embed embed>";
alert(document.getElementById('pippo').value);
</script>

this work as expected, in php you can't do that.

(i know that javascript is a client side script, I use it just as an example of a DOM abstraction)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 20:01:35 2025 UTC