Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.5.6

Bug #9416 HTML_AJAX_Action not assigning certain attributes to <select> nodes
Submitted: 2006-11-22 12:09 UTC Modified: 2006-11-27 20:19 UTC
From: jazzslider at gmail dot com Assigned:
Status: Bogus Package: HTML_AJAX (version 0.5.0)
PHP Version: 5.1.4 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2006-11-22 12:09 UTC] jazzslider at gmail dot com (Adam)
Description: ------------ When creating or replacing <select> elements via HTML_AJAX_Action::createNode and HTML_AJAX_Action::replaceNode, the attributes passed in as the third argument are presumably not being assigned. I noticed this when trying to first replace an existing <select> element and then create <option> children to append to it; since the ID attribute of the new <select> element is not being assigned, the <option> children are not being added to anything (JavaScript says that document.getElementById('theNewSelect') has no properties). Test script: --------------- function updateSelect($id) { $response = new HTML_AJAX_Action(); $attr = array('id' => $id, 'name' => $id); $response->replaceNode($id, 'select', $attr); for ($i=1;$i<=10;$i++) { $attr = array('value' => $i, 'innerHTML' => 'Option ' . $i); $response->createNode($id, 'option', $attr, 'append'); } return $response; } Expected result: ---------------- When the function above is called through a proper HTML_AJAX_Server (via JavaScript from some already-loaded page), the element with ID $id should be replaced with a select menu containing the ten options generated above. Actual result: -------------- The element with ID $id is instead replaced by an empty <select> element with no ID, no name, and no <option>s. Note that, if the initial replaceNode() call replaces the ID'd element with a <div> instead of a <select> and assigns innerHTML and no <option>s, this works fine. It seems to be a problem unique to <select>/<option> elements (although I'm not sure that the ID attribute gets set for the <div> either; innerHTML works, though).

Comments

 [2006-11-22 14:09 UTC] auroraeosrose at php dot net (Elizabeth Smith)
I cannot verify this with HTML_AJAX svn on PHP 5.2 - I just submitted some changes to the guestbook example using this code and it works just fine on both Firefox 2 and IE 6 & 7 on WinXPSP2 Please try checking out the current svn code and testing the guestbook example (at the bottom where the select item is located) Also what browser are you using? Some browsers have trouble with dom manipulation (which is why the HTML_AJAX_Action class is geared more towards the use of the innerHTML attribute)
 [2006-11-27 20:19 UTC] auroraeosrose at php dot net (Elizabeth Smith)
Example works - user implementation issue