Edit report at https://bugs.php.net/bug.php?id=61376&edit=1

 ID:                 61376
 Comment by:         jrbeaure at uvm dot edu
 Reported by:        jrbeaure at uvm dot edu
 Summary:            saveHTML only allows one option element to have the
                     selected attribute.
 Status:             Open
 Type:               Bug
 Package:            DOM XML related
 Operating System:   Linux (Unknown Derivative)
 PHP Version:        5.3.10
 Block user comment: N
 Private report:     N

 New Comment:

I forgot to mention in the description my work around.
I use saveXML instead, which works. However, this also breaks my code because 
the CDATA node markup in script tags cause the scripts to break in browsers, 
regardless of whether it's the official standard. To get around this I used 
preg_replace to surround the <![CDATA[]]> markup with javascript /*comment*/ 
markup.


Previous Comments:
------------------------------------------------------------------------
[2012-03-13 15:30:33] jrbeaure at uvm dot edu

Description:
------------
I've been having a very hard time trying to use the DOMDocument class for this 
purpose, and it's taken me three days to figure out how to work around the bugs.

When loading elements from different selects:

If there is a presently selected option, I remove the selected attribute from 
the option using the DOMElement removeAttribute method.

Then I use the DOMElement setAttribute method to set the attribute 'selected' 
to the value 'selected'.

I do this for two different options that are children of two different select 
elements.



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61376&edit=1

Reply via email to